01.web.xml
web.xml 분석
- context-param
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee https://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<!-- The definition of the Root Spring Container shared by all Servlets
and Filters -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/root-context.xml</param-value>
</context-param>
context-param은 아래의 contextLoaderListener의 파라미터이다
contextLoaderListener가 로딩 할 자바 빈들이 위의 root-context에 있다
root-context를 밑으로 dispatcher 서블릿들이 위치를 한다
root-context는 공통적인 분모들(스프링 시큐리티)는 root에 로드 해준다
dispathcher sevlet가 여러개일 떄 root-context에 로딩하기도 한다
- ContextLoaderListener
<!-- Creates the Spring Co ainer shared by all Servlets and Filters -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
contextLoaderListener가 root-context를 로딩하게 된다
- servlet
<!-- Processes application requests -->
<servlet>
<servlet-name>appServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<init-param>
<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>
<servlet-mapping>
<servlet-name>appServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
root요청은 appServlet가 받는다
app 서블릿은 dispathcher 서블릿이 받으며 dispatcher서블릿은 파라미터를 servlet-context를 가지고 로딩된다
- errorpage
<!-- 에러페이지 -->
<error-page>
<error-code>404</error-code>
<location>/WEB-INF/views/404Error.jsp</location>
</error-page>
- 한글 깨짐 필터
<!-- Character Encoding 한글깨짐 방지 필터 -->
<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-name>encodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
댓글남기기