HTTP 请求编码 Weblogic/Resteasy 模拟
使用 XHR 通过网络发送瑞典文本,我的理解是字符集编码强制为默认 UTF-8:
Content-Type application/json; charset=UTF-8
选择后,servlet 请求会变得混乱(即瑞典字符 äÖÅ)。尝试通过将 webapp.encoding.default 参数设置为 UTF-8,通过 weblogic-application.xml 在 Weblogic 容器中全局获取请求。没有区别。还想使用我的 Resteasy 设置进行本地测试,但模拟框架也混乱了文本。创建一个 PreProcessInterceptor 以在移交到底层服务之前检查文本,并存在同样的问题。我可以使用拦截器来强制编码,但似乎我缺少一些简单的东西(即处理编码/解码的通用方法)。
假设我在 FireBug 中看到的采用 UTF-8 编码的 POST 数据看起来不错(没有混乱),一旦到达服务,文本就会混乱,所以问题是 servlet 编码?
Sending swedish text over the wire with XHR and my understanding is that character set encoding is forced to default UTF-8:
Content-Type application/json; charset=UTF-8
Upon pick the servlet request gets jumbled (i.e. swedish characters ÄÖÅ). Tried getting at the requests globally in the Weblogic container via the weblogic-application.xml by setting the webapp.encoding.default parameter to UTF-8. No difference. Want to also test locally with my Resteasy setup but the mock framework jumbled text as well. Created a PreProcessInterceptor to check the text prior to handover to the underlying service and same problem there. I could use the interceptor to force an encoding but it seems I am missing something simple (i.e. a general way to handle encoding/decoding).
Assumption is that the POST data i see in FireBug with the UTF-8 encoding looks good (no jumbling) and once it hits the service the text is jumbled so the problem is the servlet encoding?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
见评论。只需将 -Dfile.encoding 更新为 UTF-8 即可正常工作。
See comment. Just update the -Dfile.encoding to UTF-8 and things work fine.