java response.sendRedirect 传递汉字乱码的解决办法
2019/11/3 10:24:55 | 阅1501 | 来源:好空间网络 [打印] [关闭] |
在java中使用 response.sendRedirect();方法传递汉字会有乱码的问题
String host="这里是汉字"; response.sendRedirect("../admin/index/jm_getDiQu.jsp?id="+host);
我们需要修改为
String host="这里是汉字"; host = java.net.URLEncoder.encode(host,"UTF-8");//由于在response.sendRedirect 汉字会有乱码,所以在这里进行了下编码 response.sendRedirect("../admin/index/jm_getDiQu.jsp?id="+host);
这样就不会乱码啦~~