Tomcat get request parameters Chinese garbled

Scene: Tomcat container using a Chinese way of passing parameters to get back garbled. 
The reason: Tomcat default encoding is ISO - 8859 - 1 . 
Solution: 
  1 . Cofg-server.xml provided in <Connector> 
    EG: <Connector Port = " 8080 " Protocol = " the HTTP / 1.1 " connectionTimeout = " 20000 " the redirectPort = " 8443 " the URIEncoding = " UTF-. 8 " / > 
    Analysis: the URIEncoding = " UTF-. 8 "  // encoding format set url url content when transfer 
        compression = "   // Open compression  
        compressionMinSize = " 2048 "   // Enable compressed output content size, there is a default 2KB 
        noCompressionUserAgents = " GoZilla, Traviata "  // For the following browsers, do not enable compression 
        compressableMimeType = " text / HTML, text / xml "    // compression type 

  2 . when using the get way to pass the Senate will be Chinese parameters into a format of the URL. I.e., after use or urlDecode urlEncode conversion (beginning with a percent sign) and then transmitted. 
      Note: in this way need to pay attention to two places: 1 . Taiwan before and after treatment must be the same, that is to say the front end of the back-end using urlEncode also use urlEncode. 2 . Chinese transcoding parameters first and then stitching. Otherwise it will be converted off other locator.

 

Guess you like

Origin www.cnblogs.com/tanjiyuan/p/11547779.html