<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-4.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.1.xsd">
<!-- The controllers are auto-detected POJOs labeled with the @Controller
annotation. -->
<context:component-scan
base-package="com.portfolio.www" use-default-filters="false">
<context:include-filter type="annotation" expression="org.springframework.stereotype.Controller" />
<context:include-filter type="annotation" expression="org.springframework.stereotype.Component" />
</context:component-scan>
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/views/" />
<property name="suffix" value=".jsp" />
</bean>
<mvc:resources mapping="/resources/**" location="/resources/" />
<mvc:annotation-driven />
</beans>
pf servlet 파일에서 자동/수동 빈 등록 및 스캔을 지정해준다.
- beans : spring 빈 설정 파일의 최상위 요소(기본)
- context:component-scan : 지정된 패키지에서 컴포넌트(에너테이션을 지정한)를 검색해서 자동으로 빈 등록
- bean : 수동으로 빈 등록, InternalResourceViewResolver를 등록하고 /WEB-INF/views/ 폴더의 jsp 뷰를 해석
- mvc:resources : mapping 요청 경로에 대한 매핑을 지정하고, location은 실제 정적 리소스 파일이 위치한 폴더를 지정한다.
- mvc:annotation-driven : 에노테이션 기반 MVC를 활성, 만약 해당 값이 설정되어 있지 않다면 @Controller, @RequestMapping을 사용할 수 없다.