I have a use case where i am submitting parameters to spring controller through post request. In the controller, i am reading parameters and performing some actions. After that i am sending those parameters as part of request params to other URL.
Here i am not able to deal with chinese characters. It is getting garbled.
Actions i am doing now : 1) I am passing below Chinese text as param with name subject from HTML page(this is not JSP). 以下便是有关此问题的所有信息
2) When i read this value from request in controller, it is coming as : 以ä¸ä¾¿æ¯æå³æ¤é®é¢çææä¿¡æ¯
3) I am not able to get the exact value that is submitted from page.
It looks like it is already encoded when i verify the encoded text at below url : http://coderstoolbox.net/string/#!encoding=none&action=encode&charset=utf_8 http://www.cafewebmaster.com/online_tools/utf_decode
4) Now i want to pass the actual user submitted string to other URL as response.sendRedirect. I tried decoding the URL to see if i can get the actual string but no success.
I am using tomcat server. I have defined UTF-8 encoding in server.xml and added a URLEncodingFilter in web.xml as first filter mapping. This filter do the request.setEncoding to UTF-8.
Still i am not able to track where things are going wrong. Can someone suggest me how to get back the actual string in controller?
Also have below filter in my 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>
Let me know if you need any information to get more context.
If you are using, please change the Connector in the server.xml file as below
<Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1"
redirectPort="8443" useBodyEncodingForURI="true">
</Connector>
Hope this solves your problem.
Regards, Kishore