使用Tomcat——表单中的中文服务端接收到为乱码

来源:互联网 发布:用友软件使用方法 编辑:程序博客网 时间:2024/05/04 03:42

网页一般都是用UTF-8编码,因此表单中的中文也是UTF-8的,传给服务器的自然也是按照utf-8编码的中文。而傻缺的Tomcat默认的解码却是ISO。把UTF-8的码用ISO来解当然会乱码。所以,需要在Tomcat的Server.xml上配置解码方式。

在server.xml中,找到

<Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443"/>
更改为:

<Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443" URIEncoding="UTF-8"/>

重启服务器,问题解决。

0 0