
web.xml
context-param
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/root-context.xml</param-value>
</context-param>
- 실제 애플리케이션을 구동할 때 실행되는 xml 설정(/WEB-INF/spring/root-context.xml)
- ContextLoaderListener에서 Root WebApplicationContext를 생성하기 위한 설정 파일의 경로 지정
listener - ContextLoaderListener
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
ContextLoaderListener
- 웹 애플리케이션의 시작, 종료 이벤트에 대한 이벤트 리스너이다.
- 웹 애플리케이션 구동 시 루트 애플리케이션 컨텍스트를 생성하고 웹 애플리케이션 종료 시 루트 애플리케이션 컨텍스트를 소멸한다.
DispatcherServlet
<servlet>
<servlet-name>appServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<!--
DispatcherServlet 서블릿 마다 독립적으로 생성되는 WebApplicationContext를 생성하기 위한 설정 파일의 경로 지정
-->
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
- 사용자의 요청을 받는 프론트 컨트롤러 서블릿이다.
- DispatcherServlet 서블릿 마다 독립적인 WebApplicationContext를 갖는다.
- DispatcherServlet 서블릿 마다 독립적으로 생성되는 WebApplicationContext를 생성하기 위한 설정 파일의 경로 지정
servlet-mapping
<servlet-mapping>
<servlet-name>appServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
filter
<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>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
filter-mapping
<filter-mapping>
<filter-name>encodingFilter</filter-name>
<url-pattern>/</url-pattern>
</filter-mapping>
'Spring > Spring MVC2' 카테고리의 다른 글
Board - 게시물 등록 및 수정 / 첨부 파일 인코딩 및 등록 (0) | 2022.10.24 |
---|---|
Board - 전체 게시글 / 상세 페이지 / 게시글 삭제 (1) | 2022.10.23 |
기본 설정 ③ servlet-context.xml (0) | 2022.09.02 |
기본 설정 ② root-context.xml (0) | 2022.09.02 |