본문 바로가기
Web Program

톰캣(Tomcat) UTF-8 인코딩 설정

by 학수씨 2017. 8. 24.

1.server.xml 수정


<Connector port="8080" 

maxHttpHeaderSize="8192" 

maxThreads="150" 

minSpareThreads="25" 

maxSpareThreads="75"

enableLookups="false" 

redirectPort="8443" 

acceptCount="100"

connectionTimeout="20000" 

disableUploadTimeout="true" 

URIEncoding="UTF-8" />

 

<Connector port="8009" 

enableLookups="false" 

redirectPort="8443" 

protocol="AJP/1.3" 

URIEncoding="UTF-8" />



2. web.xml에 필터 추가


<filter>

<filter-name>Set Character Encoding</filter-name>

<filter-class>filters.SetCharacterEncodingFilter</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형식 으로 저장


   1) 울트라에디트 기준 변환 방법

   -. 파일 ----> 변환 ----> ascii ->utf-8(unicode편집)



4.파일 상단에 추가


<%@pagepageEncoding="UTF-8" contentType="text/html; charset=UTF-8" %>

<%

request.setCharacterEncoding("utf-8"); 

%>



5.톰캣 실행시 -Dfile.encoding=UTF-8  추가


-Dcatalina.home=C:\Program Files\Apache Software Foundation\Tomcat 6.0

-Dcatalina.base=C:\Program Files\Apache Software Foundation\Tomcat 6.0

-Djava.endorsed.dirs=C:\Program Files\Apache Software Foundation\Tomcat 6.0\endorsed

-Djava.io.tmpdir=C:\Program Files\Apache Software Foundation\Tomcat 6.0\temp

-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager

-Djava.util.logging.config.file=C:\Program Files\Apache Software Foundation\Tomcat 6.0\conf\logging.properties

-Dfile.encoding=UTF-8



댓글