I have a web app with spring,jsp and jquery in a apache tomcat 6, one jsp page has a form that send the data with a ajax call made whit jquery, to a Spring MultiActionController
Everything looks fine until the point that you get the parameter in a variable. It's just your backend which still needs to be configured to use UTF-8. For example, the System.out.println()
or the logger where you're sending the retrieved parameter to should also use UTF-8. Or the database where you're storing the retrieved parameter should also use UTF-8. Or the JDBC driver which is interacting with that DB. Or the text file where you're writing the data to. Etcetera.
Unrelated to your concrete problem, the line
request.setCharacterEncoding("UTF-8");
should be executed before Spring kicks in. It sets the POST request encoding and this will fail whenever Spring determines the request body before executing the action (note that this line has totally no effect on GET requests). Spring has a CharacterEncodingFilter
which does exactly that. Register this in your web.xml
:
characterEncodingFilter
org.springframework.web.filter.CharacterEncodingFilter
encoding
UTF-8
forceEncoding
true
characterEncodingFilter
/*