There may be many ways to solve encoding problem:
Encoding filter like Spring MVC UTF-8 Encoding
Setting URIEncoding=UTF-8 in server.xml of Tom
for tomcat7
CharacterEncodingFilter configures encoding of request body. That is, it affects encoding of POST request parameters, etc, but doesn't affect encoding of GET parameters
useBodyEncodingForURI="true" tell tomcat to use CharacterEncoding( can be set by CharacterEncodingFilter) to parse QueryString. it's affect GET request parameter .
URIEncoding to parset URI , default is ISO-8859-1.
for tomcat8
CharacterEncodingFilter
configures encoding of request body. That is, it affects encoding of POST
request parameters, etc, but doesn't affect encoding of GET
parameters
URIEncoding
is used to specify encoding of the URI, therefore it affects GET
parameters
useBodyEncodingForURI="true"
tells Tomcat to use encoding configured for request body when decoding URIs. So, as far as I understand, if you set CharacterEncodingFilter
and useBodyEncodingForURI="true"
then you don't need URIEncoding
.
In practice, you need to two things to solve possible problems with encoding of parameters:
CharacterEncodingFilter
for POST
requests
URIEncoding
(or useBodyEncodingForURI="true"
) for GET
requests