-
인코딩(Encoding)설정하는법■ 아빠 프로그래밍/JAVA 2017. 10. 23. 13:07반응형
1. Spring 설정
web.xml 에 아래와 같이 Spring 에서 제공하는 filter를 설정해준다.
(POST를 한글처리를위한 설정)
<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>
servelt-context.xml 설정
<!-- Resolves views selected for rendering by @Controllers to .jsp resources in the /WEB-INF/views directory -->
<beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<beans:property name="prefix" value="/WEB-INF/views/" />
<beans:property name="suffix" value=".jsp" />
<beans:property name="contentType" value="text/html; charset=UTF-8" />
</beans:bean>
2. Server 설정
Server.xml
(GET 한글 처리를 위한 설정)
<Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443" URIEncoding="UTF-8"/>
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443"URIEncoding="UTF-8"/>
3. jsp 설정
<%@ page session="false" pageEncoding="UTF-8"%>
4. Mybatis 입력시 한글깨짐한글입력시깨짐문제 발생jdbc.url=jdbc:mysql://localhost:3306/디비명?useUnicode=true&characterEncoding=utf85. @ResponseBody 응답시 한글깨짐@RequestMapping(value = "/Act",produces="text/plain;charset=UTF-8")@ResponseBody6. Eclipse설정
preference->general->workspace UTF-8 Setting
preference->web->CSS UTF-8 Setting
preference->web->HTML UTF-8 Setting
preference->web->JSP UTF-8 Setting
7. JavaScript 설정
GET으로 보낼때 encodeURI() 수행
반응형'■ 아빠 프로그래밍 > JAVA' 카테고리의 다른 글
글자 자리수 맞추기 String.format() (0) 2018.04.10 BigDecimal 사용 (0) 2018.01.09 로컬컴퓨터 MAC 주소 가져오기 (0) 2017.08.22 포워딩(forwarding) (0) 2017.08.22 상속(Extends) (0) 2017.08.22