Vishal Kumar Shaw
Vishal Kumar Shaw

Reputation: 1

Character Encoding Issue with spring application

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.

Upvotes: 0

Views: 1513

Answers (2)

user1593705
user1593705

Reputation:

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.

Upvotes: 0

artbristol
artbristol

Reputation: 32407

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.

Upvotes: 1

Related Questions