Apache-Tomcat URIEncoding

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

sitelink1  
sitelink2  
extra_vars5
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>
-----------------------------------------------------------------------------------------------------------------------------------------


번호 제목 글쓴이 날짜 조회 수
26 jsp 에서 <script> 로 import 한 js 내의 한글이 깨진다 file 황제낙엽 2024.07.14 296
25 "org.apache.tomcat.util.net.SecureNioChannel.getSslEngine()" is null 황제낙엽 2023.06.22 242
24 windows tomcat 에 Let's Encrypt(SSL) 적용 황제낙엽 2023.06.21 285
23 [Tomcat 7] org.apache.tomcat.util.bcel.classfile.ClassFormatException: Invalid byte tag in constant pool: 15 황제낙엽 2019.10.16 462
22 톰캣과 방화벽 file 황제낙엽 2019.09.17 261
21 톰캣 한글 깨짐, UTF-8 인코딩 설정[2] file 황제낙엽 2018.08.23 1268
20 톰캣 한글 깨짐, UTF-8 인코딩 설정[1] [1] file 황제낙엽 2018.08.23 3635
19 이클립스는 괜찮은데 톰캣에서만 한글깨짐 (윈도우 콘솔의 다국어 인코딩 포함) file 황제낙엽 2018.08.23 3166
18 캐시 여유 공간 부족 (insufficient free space) 해결 황제낙엽 2018.03.16 4431
17 무설치 포터블(portable) 톰캣을 윈도우 서비스로 등록하기 황제낙엽 2017.11.07 479
16 구버전의 톰캣 실행하기 황제낙엽 2017.03.22 243
15 Tomcat 8에 SSL 인증서를 적용 황제낙엽 2016.12.23 1768
14 Server.xml 에 Context 추가 황제낙엽 2012.09.19 248
13 톰캣 메모리 확장 시키기 file 황제낙엽 2012.02.01 360
» URIEncoding 황제낙엽 2011.05.12 215
11 톰캣의 URI encoding 설정하기 황제낙엽 2011.05.12 194
10 Post too large 황제낙엽 2010.08.06 244
9 아파치와 톰캣 연동 및 로드 발란싱 구현 (포스데이타) file 황제낙엽 2010.05.06 208
8 톰캣 5.x 에서의 URI 한글 인코딩 문제..(Set Character Encoding) 황제낙엽 2008.01.30 420
7 Howto Install Tomcat 5 + Apache 2 in WinXP 황제낙엽 2007.10.31 182