tomcat5中,為了保證get資料采用UTF8編碼,在server.xml中進行了如下設定:
<Connector port="8080" maxThreads="150" minSpareThreads="25"
maxSpareThreads="75" enableLookups="false" redirectPort="8443"
acceptCount="100" debug="99" connectionTimeout="20000"
disableUploadTimeout="true" URIEncoding="UTF-8"/>
這裡指定了get時候的資料編碼。但是,當使用IIS作為webserver轉發servlet/jsp請求給Tomcat時候,這個設定卻失效了。其實原因很簡單:IIS是通過AJP協定,把請求轉發到Tomcat監聽的8009端口上的,是以這裡針對8080的設定自然就無效了。正确的方法是進行下面的設定:
<Connector port="8009" enableLookups="false" redirectPort="8443"
debug="0" protocol="AJP/1.3" URIEncoding="UTF-8"/>