传数据不能为中文,而是乱码

来源:互联网 发布:mysql的事务隔离级别 编辑:程序博客网 时间:2024/05/16 05:16

1、前台传参到后台乱码

1>

修改apache-tomcat-7.0.73\conf\server.xml中

  <Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" 
       />

将URIEncoding="utf-8"添加上去

2>

在后台接受参数时,改格式
String type=request.getParameter("orderRefundType");type=new String(type.getBytes("iso-8859-1"),"utf-8");

2、传json数据到前台乱码

@RequestMapping(value = "/insertFeedback", produces = "text/html;charset=utf-8")@ResponseBody


阅读全文
1 0