Q: Spring mvc filter doesn't take effect I'm learning SpringMVC. The version I use is 4.2.5.RELEASE. The filter I configure in web.xml doesn't seem to work
Server: Tomcat 7
Problem : When I use the GET method to pass in Chinese parameters, even if I configure the filter for UTF-8 encoding conversion, but the string I get is still garbled 
web.xml:
<filter>
    <filter-name>encodingFilter</filter-name>
    <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
    <init-param>
        <param-name>encoding</param-name>
        <param-value>UTF-8</param-value>
    </init-param>
    <init-param>
        <param-name>forceEncoding</param-name>
        <param-value>true</param-value>
    </init-param>
</filter>
<filter-mapping>
    <filter-name>encodingFilter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

I consider my configuration is not wrong
Controller:
@RequestMapping(value = "/user/info", method = RequestMethod.GET)
public String getInfo(HttpServletRequest request,
                      @RequestParam("username") String username, Model model) {

    UserInfo userInfo = new UserInfo(username, "xxx", "xxx");
    Logger.i(userInfo.toString());
    model.addAttribute("info", userInfo);
    return "user/info";
}

When I pass in the Chinese parameters, the information printed by the console is garbled, and it is garbled to return to the front.
And request.getCharacterEncoding() return is "UTF-8"
But when i use:
try {
    username = new String(username.getBytes("ISO-8859-1"), "UTF-8");
} catch (UnsupportedEncodingException e) {
    e.printStackTrace();
}

It can display normally.
So I changed the default encoding of Tomcat and changed it to UTF-8. After that, even if I don't perform transcoding in the code, I can get the correct parameters.
Question: So I am very puzzled that the filter has no effect.
I would like to express my heartfelt thanks for your enthusiasm. Thanks!

A: Have you tried configuring Tomcat's server.xml? Try setting URIEncoding="UTF-8" attribute to a Connector component:
<Connector port="8080" protocol="HTTP/1.1"
           connectionTimeout="20000"
           URIencoding="UTF-8"
           redirectPort="8443" />

You can get more information here
