2016년 2월 20일 토요일

[sw theroy] spring framework 의 annotation 들에 대해서 간략히 설명하시오.


@RestController
stereotype annotation이라고 함. 
이 클래스가 특별한 역할을 한다고 알려주는 annotation 임.
들어오는 웹 리퀘스트를 처리할 때 프레임워크에서 살펴봄. 

@RequestMapping 
라우팅 정보를 나타냄. 
HTTP request 의 path를 바탕으로 함수 매핑을 해주는데 사용됨. 

Spring Web MVC 프레임워크는 DispatcherServlet 을 기반으로 하여 요청을 핸들러에게 보내준다. 
기본적으로 @Controller와 @RequestMapping 어노테이션으로 요청 핸들링을 명세한다. 

스프링 3.0 이후부터 @PathVariable 을 통해서 RESTful Web site를 만들기 쉽게 되었다. 

스프링 프레임워크의 주요 디자인 원칙은 "확장에 열리고, 수정에 닫히고" 이다. 
"Open for extension, closed for modification"
그래서 core 클래스들은 final로 정의되어, 개발자가 수정할 수 없다. 
Controller 의 역할은 일반적으로 view 이름과 데이터를 엮은 Model Map을 준비하는 것이다. 
또한 Controller 단에서 바로 데이터 response해서 요청을 대응할 수도 있다.

@EnableAutoConfiguration annotation

This annotation tells Spring Boot to “guess” how you will want to configure Spring, based on the jar dependencies that you have added. Since spring-boot-starter-web added Tomcat and Spring MVC, the auto-configuration will assume that you are developing a web application and setup Spring accordingly.

@ResponseBody

댓글 없음:

댓글 쓰기