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

相關文章
相關標籤/搜索