Web.xml을 세팅한 뒤 servlet에 명시한 대로 front.xml 파일을 생성했다. 



여기서는 빈 객체를 자동으로 등록하기 위한 context-component-scan, mvc 기반에서 어노테이션을 자동으로 입력해주는 mvc:annotation-driven 그리고 restFul을 적용하기 위해 jsp 파일과 images 파일 자원을 분리하기 위한 mvc:resources를 사용했다. 



 restFul의 경우 확장자를 명시하지 않은 형태의 유연한 코드가 특징인데, 이미지 파일의 경우 특정 확장자가 고정되어 있기 때문에 정적 자원은 별도의 분리를 해줘야 한다. 


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:p="http://www.springframework.org/schema/p"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd">
 
<!-- 자동 bean 객체 등록 -->
<context:component-scan base-package="com.p_rest"></context:component-scan>
 
<!-- mvc 기반에서 어노테이션을 자동으로 입력하기 위함 -->
<mvc:annotation-driven/>
 
<!-- restFul 적용을 위해서는 동적 자원과 정적 자원을 분리해야 한다. -->
<mvc:resources location="/images/" mapping="/images/**"></mvc:resources>
 
</beans>
cs


+ Recent posts