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.

Nandkumar Tekale
  • 16,024
  • 8
  • 58
  • 85

2 Answers2

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.

Community
  • 1
  • 1
artbristol
  • 32,010
  • 5
  • 70
  • 103
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.