我正在尝试从请求中读取 UTF-8 信息。 我使用了“request.setCharacterEncoding("UTF-8");”,但它似乎什么也没做 - 读取的信息不是 UTF-8。
我做错了什么?
最佳答案
如果您使用的是 tomcat,您还应该在连接器中将 URIEncoding 设置为 UTF-8:
<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>
关于java - HttpServletRequest - setCharacterEncoding 似乎什么都不做,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3278900/