Apache-Tomcat URIEncoding

황제낙엽 2011.05.12 18:02 조회 수 : 924

extra_vars5 1 
extra_vars6 ko 

This specifies the character encoding used to decode the URI bytes, after %xx decoding the URL. If not specified, ISO-8859-1 will be used.


 

데이터를 URL 인자로 보낼 때, 특정 Character Encoding 의 스트링을, 브라우저가 URL Encoding 으로 싸서 보내는데,
Tomcat 이 URL Encoding 은 벗길 수 있지만, 원래 스트링의 Character Encoding 은 알 수가 없습니다.
Connector 에 URIEncoding 어트리뷰트를 적어서 Character Encoding 을 알려줍니다.
Post 시 Body Encoding 은 이것과 상관 없습니다.


 

tomcat 5.x 버전에서 웹브라우저로 부터 날라온 Get/Post 로 전달되는 한글이 ISO8859-1로 넘어오는 경우가 있어
한글이 깨지는 경우가 있습니다. 아래와 같이 Get / Post로 넘오는 한글 처리를 하시면 됩니다.
 
1. Get 방식으로 넘어오는 파라미터

[server.xml]
-----------------------------------------------------------------------------------------------------------------------------------------
   <Connector
               port="8080"               maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
               enableLookups="false" redirectPort="8443" acceptCount="100"
               debug="0" connectionTimeout="20000"
               disableUploadTimeout="true" useBodyEncodingForURI="true" URIEncoding="KSC5601"/>
-----------------------------------------------------------------------------------------------------------------------------------------

2. Post 방식으로 넘오는 파라미터

2-1. 톰캣이 설치된 디렉토리에서

<TOMCAT_HOME>/webapps/jsp-examples/WEB-INF/classes/filters/SetCharacterEncodingFilter.class 파일을 복사해서
<TOMCAT_HOME>/common/classes/filters/ 밑으로 복사함.

2-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>euc-kr</param-value>
      </init-param>
    </filter>

    <filter-mapping>
      <filter-name>Set Character Encoding</filter-name>
      <url-pattern>/*</url-pattern>
    </filter-mapping>
-----------------------------------------------------------------------------------------------------------------------------------------


번호 제목 글쓴이 날짜 조회 수
73 [ChatGPT] nginx 에서 jetty 서버로 프록시중 "org.eclipse.jetty.http.BadMessageException: 400: Invalid SNI" 오류 황제낙엽 2024.11.12 1291
72 [phind] jetty 와 tomcat 의 차이점 (성능, 사용성, 선호도) 황제낙엽 2024.10.31 1438
71 jsp 에서 <script> 로 import 한 js 내의 한글이 깨진다 file 황제낙엽 2024.07.14 1481
70 Nginx: 413 – Request Entity Too Large file 황제낙엽 2024.02.17 1187
69 nginx 설치, 실행, SSL 설정, 프록시 설정 황제낙엽 2024.02.04 962
68 [bard] Nginx로 서브 도메인에 따라 내부의 포트만 다르게 실행중인 웹서버들을 라우팅 황제낙엽 2024.02.01 962
67 [Bing] "Apache"와 "Nginx" 의 차이점 황제낙엽 2024.01.31 1055
66 Nginx 에 대하여 황제낙엽 2024.01.18 892
65 "org.apache.tomcat.util.net.SecureNioChannel.getSslEngine()" is null 황제낙엽 2023.06.22 2956
64 windows tomcat 에 Let's Encrypt(SSL) 적용 황제낙엽 2023.06.21 1093
63 AutoSet PHP 버전 업그레이드 (7.2.10 to 7.4.32) 황제낙엽 2022.10.09 1542
62 401 - Unauthorized: Access is denied due to invalid credentials 황제낙엽 2021.08.27 1387
61 iis error - Service Unavailable / HTTP Error 503. The service is unavailable. 황제낙엽 2020.09.23 1739
60 [Bitnami WAMP] 설치후 PHP 설정 황제낙엽 2020.07.23 1631
59 Autoset의 대안 Bitnami WAMP file 황제낙엽 2020.04.01 1034
58 HTTP 오류 403.14 - Forbidden file 황제낙엽 2020.03.04 964
57 바인딩 편집 (사이트 바인딩) file 황제낙엽 2020.03.04 1021
56 웹사이트에서 여러 도메인을 사용하는 방법 황제낙엽 2020.03.04 1387
55 32비트 응용 프로그램 사용 (ASP, C#) file 황제낙엽 2019.10.31 3056
54 [Tomcat 7] org.apache.tomcat.util.bcel.classfile.ClassFormatException: Invalid byte tag in constant pool: 15 황제낙엽 2019.10.16 1231