mjeongriver

1. GET방식 한글 깨짐
이클립스 server.xml 에서 port=8080과 port=8009두개의 connector에 URIEncoding="UTF-8"을 추가한다.

    <Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443"  URLEncoding="UTF-8"/>
    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" URLEncoding="UTF-8"/>


2. POST 방식에서 한글 깨짐(mapping 빠짐)
web.xml 아래와 같이 filter class 를 등록
...
  <filter>
    <filter-name>Set Character Encoding</filter-name>
    <filter-class>filters.SetCaharterEncodingFilter></filter-class>
    <init-param>
      <param-name>encoding</param-name>
      <param-value>UTF-8</param-value>
    </init-param>
  </filter>
  
  <filter-mapping>
    <filter-name>Set Character Encoding</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>

 

3. 소스파일 (jsp)에 utf-8 내용 추가
<%@pagepageEncoding="UTF-8" contentType="text/html; charset-"UTF-8" %>

<%
request.setCharacterEncoding("utf-8");
%>


4. 톰캣 실행시 -Dfile.encoding=UTF-8 추가
-Dcatalina.home=C:\apache-tomcat-8.5.12
-Dcatalina.base=C:\apache-tomcat-8.5.12
-Djava.endorsed.dirs=C:\apache-tomcat-8.5.12\endorsed
-Djava.io.tmpdir=C:\apache-tomcat-8.5.12\temp
-Djava.util.logging.manager=org.apache.juil.ClassLoaderLogManager
-Djava.util.loggin.config.file=C:\apache-tomcat-8.5.12\conf\logging.properties
-Dfile.encodeing=UTF-8

 

참조

https://www.happyjung.com/lecture/2360?sca=JSP&sst=wr_datetime&sod=desc&sop=and 

 

 

profile

mjeongriver

@mjeongriver

포스팅이 좋았다면 "좋아요❤️" 또는 "구독👍🏻" 해주세요!

검색 태그