作为 WAR 部署或在 Tomcat 下运行时出现 UTF-8 问题
在我的 grails 应用程序中,当我在 Tomcat 下运行时,UTF-8 处理被搞砸了。当我运行应用程序时,以下请求字符串:
utf-8-demo-%C3%BC%C4%81%D1%84.txt
设置为 utf-8-demo -üāф.txt
,为所有后续请求的字符串中的每个 unicode 字符发送回 3 个 unicode 转义序列。
在 tomcat 下,它返回为 utf-8-demo-ü.txt
或 utf-8-demo-\u00C3\u00BC\u00C4\u0081\u00D1\u0084.txt.
在我的一个控制器中,我有这样的情况:
String s = params.file
log.info( "Filename: $s" )//works in run-app, fails under tomcat
什么可能导致运行应用程序和在 tomcat 下部署为战争之间的这种行为二分法?
In my grails application, UTF-8 handling is screwed up when I run under Tomcat as a war. When I do run app, the following request string of:
utf-8-demo-%C3%BC%C4%81%D1%84.txt
is set to utf-8-demo-üāф.txt
, with 3 unicode escape sequences sent back for each of the unicode characters in the string for all subsequent requests.
Under tomcat, this comes back as utf-8-demo-üÄÑ.txt
, or utf-8-demo-\u00C3\u00BC\u00C4\u0081\u00D1\u0084.txt
.
In one of my controllers, I have this:
String s = params.file
log.info( "Filename: $s" )//works in run-app, fails under tomcat
What could POSSIBLY be causing this behavior dichotomy between run-app and deploying as a war under tomcat?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在
server.xml
中的
定义中添加属性URIEncoding="UTF-8"
。Add the attribute
URIEncoding="UTF-8"
on the<Connector>
definition inserver.xml
.