SpringFramework 06. Controller - swkim0128/PARA GitHub Wiki
-
@Controller와 @RequestMapping선언
method 단위의 mapping이 가능
DefaultAnnotationHandlerMapping과 AnnotationHandlerAdapter를 사용함
- Spring 3.0 부터는 기본 설정이므로 별도의 추가 없이 사용 가능
-
Controller Class는 Client의 요청을 처리
-
@Controller 선언
Class 타입에 적용
Spring 3.0 부터는 @Controller 사용을 권장
-
Controller Class 를 에 등록
-
@Requestmapping 선언
요청 URL mapping 정보를 설정
클래스타입과 메소드에 설정 가능
-
Controller method의 HTTP method에 한정
같은 URL 요청에 대하여 HTTP method(GET, POST) 에따라 서로 다른 메소드를 mapping할 수 있음.
-
아래의 Controller에서 @RequestMapping annotation을 설정하지 않으면? HTTP ERROR 404
-
Controller method의 parameter type
Controller method의 parameter로 다양한 Object를 받을 수 있음.
-
Controller emthod의 parameter type
Controller method의 parameter로 다양한 Object를 받을 수 있음.
-
@RequestParam annotation을 이용항 parameter mapping
-
HTML form과 Command Object(DTO, VO..).
SpringMVC는 form에 입력한 data를 JavaBean 객체를 이용해서 전송할 수 있음.
-
Cammand 객체를 List로 받기
-
View에서 Command 객체에 접근
Command 객체는 자동으로 반환되는 Model에 추가됨.
Controller의 @RequestMapping annotation method에서 전달받은 Command 객체에 접근
-
@RequestBody parameter type
-
Servlet API 사용
HttpSession의 생성을 직접 제어해야 하는 경우
Controller가 Cookie를 생성해야 하는 경우
Servlet API를 선호하는 경우
-
Controller Class에서 method의 return type 종류