HttpServletRequest - setCharacterEncoding似乎什么也不做 [英] HttpServletRequest - setCharacterEncoding seems to do nothing

查看:259
本文介绍了HttpServletRequest - setCharacterEncoding似乎什么也不做的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试从请求中读取UTF-8信息。
我使用request.setCharacterEncoding(UTF-8);,但它似乎什么也不做 - 信息读取是非UTF-8。

I am trying to read UTF-8 info from the request. I used "request.setCharacterEncoding("UTF-8");", but it seems to do nothing - the info read is non UTF-8.

推荐答案

如果您使用的是tomcat,您还应将URIEncoding设置为UTF-连接器:

If you are using tomcat, you should also set the URIEncoding to UTF-8 in your connectors:

<Server port="8105" shutdown="SHUTDOWN">
...
    <Service name="Catalina">
        <Connector port="8180" URIEncoding="UTF-8" />
        <Engine name="Catalina" defaultHost="localhost">
            <Host name="localhost" appBase="webapps" />
        </Engine>
    </Service>
</Server>

这篇关于HttpServletRequest - setCharacterEncoding似乎什么也不做的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆