1 번째 방법
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 | <!-- 캐릭터 인코딩 필터 설정 --> <!-- 컨트롤러에서 response.setCharacterEncoding()를 매번 실행하지 않기 위해 서블릿 필터를 이용해 처리 --> <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> <!-- jsp 파일 utf-8 페이지 인코딩 설정 <%@ page pageEncoding="UTF-8" %> --> <jsp-config> <jsp-property-group> <url-pattern>*.jsp</url-pattern> <page-encoding>UTF-8</page-encoding> </jsp-property-group> </jsp-config> | cs |
web.xml에 필터를 추가해주면 된다
2번째 방법
출처 : http://fruitdev.tistory.com/64
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | <!-- 1. POST 전송시 한글깨짐 JSP 페이지 상단에 request.setCharacterEncoding 을 명시한다. --> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %> <%@page import="java.util.*"%> <% request.setCharacterEncoding("UTF-8"); %> <!-- 2. GET 전송시 한글깨짐 Tomcat의 server.xml에 URIEncoding 옵션을 추가해 준다. --> <Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" URIEncoding="UTF-8" /> | cs |
'Spring' 카테고리의 다른 글
로그 관련 라이브러리 (0) | 2017.12.27 |
---|---|
aspectj 라이브러리, AOP 연관 라이브러리 (0) | 2017.12.27 |
Spring에서 annotation 가능하게 하기 (0) | 2017.12.27 |
Spring framework 라이브러리 build.gradle (0) | 2017.12.27 |