Get Parameter Encoding

后端 未结 2 1105
自闭症患者
自闭症患者 2020-12-01 09:05

I have a problem using spring mvc and special chars in a GET request. Consider the following method:

@RequestMapping(\"/update\")
public Object testMethod(@R         


        
2条回答
  •  伪装坚强ぢ
    2020-12-01 09:28

    You're having this problem, because the request differentiates between body encoding and URI encoding. A CharacterEncodingFilter sets the body encoding, but not the URI encoding.

    You need to set URIEncoding="UTF-8" as an attribute in all your connectors in your Tomcat server.xml. See here: http://tomcat.apache.org/tomcat-6.0-doc/config/ajp.html

    Or, alternatively, you can set useBodyEncodingForURI="True".

    If you're using the maven tomcat plugin, just add this parameter:

    mvn -Dmaven.tomcat.uriEncoding=UTF-8 tomcat:run

提交回复
热议问题