Spring 으로 작업을 하기 위한 초기 매핑 작업이다. 필요에 따라 설정이 추가 되지만 가장 기본적인 게시판 구현을 위한 세팅코드를 정리했다.

 

 Web.xml을 작성한 뒤에는 servlet에 명시한 front.xml을 생성한다. 



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
 <!-- context 초기화를 위한 파라미터 -->
  <context-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>classpath:com/p_rest/service/service.xml</param-value>
  </context-param
 
<!-- 설정 파일을 제어하기 위해 Listener 클래스 입력 -->
<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
 
<!-- 서블릿 매핑 전에 한글 지원이 되도록 세팅 -->
<filter>
    <filter-name>encodingFilter</filter-name>
    <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
    <init-param>
        <param-name>encoding</param-name>
        <param-value>UTF-8</param-value>
    </init-param>
</filter>
 
<filter-mapping>
    <filter-name>encodingFilter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>
 
<!-- 모든 요청을 하나의 진입점으로 모으기 위한 서블릿 매핑  -->
<servlet>
    <servlet-name>dispatcher</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>WEB-INF/front.xml</param-value>
    </init-param>
</servlet>
 
<servlet-mapping>
    <servlet-name>dispatcher</servlet-name>
    <url-pattern>*.do</url-pattern>
</servlet-mapping>
 
</web-app>
 
cs



+ Recent posts