Tomcat 配置解决中文乱码和链接超时

Tomcat里面conf中的server.xml测试

 <Connector port="80" protocol="HTTP/1.1"
               connectionTimeout="20"
               redirectPort="443"
               disableUploadTimeout="true" useBodyEncodingForURI="true"
               URIEncoding="utf-8"/>

connectionTimeout:设置链接的超时值,以毫秒为单位。默认值为60000=60秒编码

设置小一些能够避免Slow HTTP Denial of Service Attack.net

disableUploadTimeOut:容许Servlet容器,正在执行使用一个较长的链接超时值,以使Servlet有较长的时间来完成它的执行,默认值为falsecode

设置为true,传输大文件时须要保持链接server

URIEncoding:用于解码URL的字符编码,没有指定默认值为ISO-8859-1xml

指定为uft-8编码,使用utf8对URI中出现的中文进行decode,例如http://localhost:8080/test/测试.do -> http://localhost:8080/test/%E6%B5%8B%E8%AF%95.doblog

useBodyEncodingForURI:主要用于Tomcat4.1.x中,指示是否使用在contentType中指定的编码来取代URIEncoding,用于解码URI查询参数,默认为falseutf-8

指定为uft-8编码,可以解决query String的乱码问题。
useBodyEncodingForURI=true -> 使用http header中指定charset进行decode(例如:Content-Type: charset=UTF-8),若未指定,则使用默认值ISO-8859-1ci

参考:io

http://blog.csdn.net/cicada688/article/details/14451541

http://blog.csdn.net/a285981079/article/details/49928399

相关文章
相关标签/搜索