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

查看:26
本文介绍了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-8:

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天全站免登陆