关于Tomcat的URIEncoding以及GET乱码

源:http://blog.csdn.net/renfufei/article/details/11294917
评:



    Service name="Catalina"> 
    <Connector port="8080" protocol="HTTP/1.1"  
               connectionTimeout="20000"  
               redirectPort="8443" URIEncoding="UTF-8" /> 
     
    <Connector port="8099" protocol="AJP/1.3" redirectPort="8443" URIEncoding="UTF-8" /> 


而Linux 的配置缺少了URIEncoding的配置项,那么默认应该是"ISO8859-1",所以如果没有配置,则需要转码一次。

[html] view plaincopy

    <!-- Linux 上Tomcat--> 
    <Service name="Catalina"> 
      <Executor name="tomcatThreadPool" namePrefix="catalina-exec-"  maxThreads="250" minSpareThreads="20"/> 
      <Connector port="80" protocol="HTTP/1.1" 
                 connectionTimeout="20000"  redirectPort="8443"  compression="on" compressionMinSize="2048" noCompressionUserAgents="gozilla,traviata" 
    ompressableMimeType="text/html,text/xml,text/javascript,text/css,text/plain,application/json,application/javascript,application/x-javascript" 
            /> 
      <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" executor="tomcatThreadPool"/> 


同理,如果在Linux上的Tomcat 加上URIEncoding="UTF-8" 就好了。

结论: 约定很重要,网站一般采用UTF-8作为默认编码。如果不是特殊需求,不要变换成其他编码。

你可能感兴趣的:(关于Tomcat的URIEncoding以及GET乱码)