Http란 인터넷의 요청과 응답을 주고 받는 통신규약을 말한다.
request와 response는 http의 소통 방식이다,
구글에 강아지를 검색한다.
->get방식을 사용한 request라고 부른다.(브라우저 검색)
자, 이제 구글에 강아지 이미지들이 뜰 것이다..
->서버가 응답 즉 Response하였다.
이러한 과정을 Request , Response방식이라고 말한다.
즉 컴퓨터들끼리 html파일을 주고받을 수 있도록 하는 소통방식을 말한다.
게시판 만들기에서도 사용하였는데 여기서 Request는 사용자가 게시판을 만들 때 글이 써지도록 요청하는 객체이며,
Response는 요청을 받아서 게시판을 생성할 때 쓰는 객체이다.
그래서 Request객체는 originFileName 과 storedFileName에 set을 써서 변경할 수 있도록 만들었다.
public class BoardVO {
public static class Response {
private int boardNo;
private String title;
private String content;
private String writer;
private String originFileName;
private String storedFileName;
private String regDate;
private String updateDate;
}
public static class Request {
private String title;
private String content;
private String writer;
@Setter
private String originFileName;
@Setter
private String storedFileName;
private MultipartFile file;
}
}
Controller부분에도 Post방식을 사용하여 사용자가 게시글을 작성할 때의 요청을 만들었다.
이때도 Request객체를 사용하였다.
@PostMapping("/board/register/add")
public ModelAndView register(@ModelAttribute BoardVO.request request){
ModelAndView view = new ModelAndView();
try{
boardService.register(request);
}catch(Exception e){
e.printStackTrace();
}
view.setViewName("views/board/board_list");
return view;
}
'Spring > [Spring]Spring 정리' 카테고리의 다른 글
@RequestParam 파라메터 매핑 (0) | 2022.01.27 |
---|---|
Multipart란? (0) | 2022.01.12 |
@bean이랑 @component 차이 (0) | 2022.01.08 |
댓글