Google App Engine 上的瑞典语字符编码错误
这是一个非常基本的问题,我很尴尬我自己还没有弄清楚。
当我在 Google App Engine 上托管的 Spring Web 应用程序中处理 HTML 表单上发布的字符串时,我应该怎么做才能保持正确的编码?
先决条件:我有一个页面,我尝试了以下编码:
meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"
meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
当有人在页面上发布带有瑞典字符 åäö 的表单时,当我查看发布的字符串(在调试器中或在已部署服务器上的持久字符串)。 (这似乎是某种转义序列,因为我的瑞典语字母后面的字母也从字符串中删除了)。
我应该更改页面上的编码还是以某种方式更改 GAE servlet 的编码?
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 string 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我正在使用 servlet 过滤器,它强制编码为 UTF-8:
我不确定是否需要,它只是来自我的 GAE 项目(以及任何其他基于 Spring 的项目)的模板,我的意思是我没有尝试过没有这个过滤器。但有了它,它工作得很好,根本没有编码问题。
当然,我总是在页面中使用 UTF-8
I'm using servlet filter, that forces encoding to be UTF-8:
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