개발공부/서버 네트워크
(2) HttpServletRequest
klyhyeon
2021. 3. 15. 08:44
728x90
HttpServletRequest
정의 : 사용자의 요청 데이터를 HTTP 서블릿에 제공하는 인터페이스 입니다. 서버에 데이터를 GET, POST 방식으로 전달할 때 HttpServletRequest로 받아줄 수 있습니다.
예시 :
서버로 formData 전송
1
2
3
4
5
6
|
var xhttp = new XMLHttpRequest();
xhttp.open("POST", "/productEdit/ajax", true);
xhttp.onload = function() {
console.log("status" + xhttp.status);
}
Xhttp.send(formData);
|
cs |
Spring Controller HttpServletRequest에서 데이터 전달받음
1
2
3
4
|
@RequestMapping(value= "/productEdit/ajax", method= RequestMethod.POST)
public void productEdit(HttpServletRequest req) throws Exception {
productEditService.imgEdit(req);
}
|
cs |