Swedish characters encoded wrong on Google App Engine
A pretty basic question, and I'm embaressed that I havn't figured it out my self.
What should I do to make the strings posted on my HTML form stay in the correct encoding when I handle them in my Spring web app hosted on Google App Engine?
Prerequisites: I have a page which I have tried the following encodings for:
meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"
meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
When someone posts a form on the page with for example Swedish characters åäö then I get questionmarks in my servlet code when I look at the posted string (in a debugger or in the persisted s开发者_开发知识库tring on the deployed server). (It seems to be an escaped sequence in some way since the letter after my Swedish letter is also deleted in the string).
Should I change encoding on the page or in some way change the encoding of GAE servlet?
I'm using servlet filter, that forces encoding to be UTF-8:
<filter>
<filter-name>Set Character Encoding</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>
<filter-mapping>
<filter-name>Set Character Encoding</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
I'm not sure that it required, it's just from my template for GAE projects (and any other Spring-based project), I mean I didn't tried it without this filter. But with it, it's working fine, no encoding problems at all.
And sure, i'm always using UTF-8 for pages
精彩评论