0

I am building an application using spring mvc and jpa using jboss7 and mysql in eclipse ide. I am having a strange problem. All my jsp pages are encoded with charset: utf8, which I think is working correctly. But whenever I try to post a data from the jsp to the controller, my data gets encoded with a different encoding style. I tried to look for the header using firebug and was astonished to see that the post request has a header with content-type : "text/plain;charset=ISO-8859-1". I have already configured the SetCharacterEncodingFilter for UTF-8 in my web.xml (it is the first filter). But still the problem exists.

I also set "org.apache.catalina.connector.URI_ENCODING" to value="UTF-8".But in vain .

Also I have added bean messageSource with property defaultEncoding set to "UTF-8".

<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource" > 

The problem still exists. Please help

Thanks in advance.

1
  • Vishal, did you get a solution to this problem? If yes, please post it here so that it helps others. Commented Oct 8, 2014 at 14:38

2 Answers 2

1

The request header is set by the browser, so your application can't control it. Usually, in your HTML form you could put an accept-charset=utf-8 attribute to specify the encoding, but that doesn't necessarily work. See this question Setting the character encoding in form submit for Internet Explorer.

Sign up to request clarification or add additional context in comments.

Comments

0

you should need to set the encoding of the JVM like follow :

-Dfile.encoding=UTF-8 -Dfile.io.encoding=UTF-8 -DjavaEncoding=UTF-8 

thus there wont be any doubt at all.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.