1.filter
모든 경로에 UTF-8적용
<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>
2. spring context 설정 -> spring 전역설정을 mybatis-context.xml로 하겠다.
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/mybatis-context.xml</param-value>
</context-param>
<listener>
context-param(spring context설정)에서 지정한 설정 파일 로드
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
3. dispatcherServlet 설정
spring mvc 핵심 서블릿 -> dispatcher 설정파일 servlet-context.xml설정
경로 : / -> 모든 경로에 dispatcher servlet 적용
load on start : 서블릿들 사이에서 첫번째로 초기화
<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>
</web-app>
https://velog.io/@lee41180612/Attiwell-mybatis