Review of Knowledge points
(1) request.setcharacterencoding ()
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/57/90/wKiom1SeFIrSutgqAAFYi3JKrbs805.jpg "title=" Request.png "alt=" Wkiom1sefirsutgqaafyi3jkrbs805.jpg "/>
The method is to set the character encoding of the request body, which tells Java what format to use for decoding.
This method is only valid for post requests because the parameters of the post request are in the request body.
(2) response.setcharacterencoding () 650) this.width=650; "Src=" http://s3.51cto.com/wyfs02/M02/57/8E/ Wkiol1sef5-dtneiaalsw7ypk4e444.jpg "title=" Response.png "alt=" Wkiol1sef5-dtneiaalsw7ypk4e444.jpg "/>
Set the character encoding of the response
(3) Uriencoding
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/57/8E/wKioL1SeGBuA9ryRAACffBi8IbE110.jpg "title=" Connector.png "alt=" Wkiol1segbua9ryraacffbi8ibe110.jpg "/>
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/57/8E/wKioL1SeGHvDqpZHAACB3OGIU5A704.jpg "title=" Sdf.png "alt=" Wkiol1seghvdqpzhaacb3ogiu5a704.jpg "/> The uriencoding attribute of the connector element in the Server.xml file specifies the character encoding of the decoded URI, which by default is Iso-8859-1
When a GET request is requested, the request parameter is appended to the URL. Therefore, the encoding specified here is valid for the GET request.
2. Actual combat
(1) Set uriencoding to UTF-8
(2) Configure filters (use spring's own filters here)
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/57/91/wKiom1SeGZGwvHCWAAJU7g00YHU574.jpg "title=" Web.png "alt=" Wkiom1segzgwvhcwaaju7g00yhu574.jpg "/>
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/57/91/wKiom1SeGamAZPBHAAUuAHTe1lY907.jpg "title=" Spring.png "alt=" Wkiom1segamazpbhaauuahte1ly907.jpg "/>
At this point, all the Get and POST request parameters are unified using UTF-8 decoding, and all the response codes are UTF-8.
This article is from the "ten-li Rice flower" blog, please be sure to keep this source http://5880861.blog.51cto.com/5870861/1596458
Using filters to solve Chinese garbled characters