스프링에서 컨트롤러 개발 시 MyBatis 연동을 위한 servlet-context.xml 파일에 대한 내용이다. 


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<annotation-driven />
 
 
<resources mapping="/resources/**" location="/resources/" />
 
 
<beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <beans:property name="prefix" value="/WEB-INF/views/" />
    <beans:property name="suffix" value=".jsp" />
</beans:bean>
 
<context:component-scan base-package="org.zerock.web" />
    
</beans:beans>
 
cs



 코드를 해석해보자. 


 annotation-driven은 클래스 선언 시 어노테이션을 이용해서 컨트롤러를 작성할 수 있게 하는 선언이다. 


 해당 선언만으로 어노테이션을 사용할 수 있게 되는 마법의(?)  설정이라 하겠다. 


 다음 org.springframework.web.servlet.view.InternalResourceViewResolver  의 경우 View를 어떻게 처리하는 것인가와 관련된 bean이다. 


 context:component-scan 마지막으로 어노테이션과 결합하여 패키지 내부의 클래스들을 스캔하여 인식하도록 하는 기능을 한다. 



+ Recent posts