json中文乱码问题

时间:2024-07-08 19:35:14

首先在 tomcat的 D:\apache-tomcat-7.0.57\conf\server.xml里添加中文编码

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

前台处理

element.value=encodeURI(value,"utf-8");

后台处理

try {
URLDecoder.decode(value,"utf-8");
} catch (Exception e) {
e.printStackTrace();
}