当前位置: 代码迷 >> Java Web开发 >> jsp页面间传值乱码有关问题
  详细解决方案

jsp页面间传值乱码有关问题

热度:45   发布时间:2016-04-17 16:24:56.0
jsp页面间传值乱码问题
在一个jsp页上传值
response.sendRedirect( "./searchresults.jsp?id= "+strID+ " ");
到下一个jsp页接值
request.getParameter(   "id ");

得到的值是乱码

拭过
1.   response.setHeader( "Cache-Control ",   "no-cache ");
      response.setHeader( "Pragma ",   "no-cache ");
      response.setDateHeader( "Expires ",   0);
      response.setContentType   ( "text/html;   charset=Windows-31J ");
2. <%@   page   language= "java "     contentType= "text/html;charset=Windows-31J "%>
还有一些别的方法,可都不行啊.


------解决方案--------------------
String name = request.getParameter( "id ");
name = new String(id.getBytes( "ISO-8859-1 "), "UTF-8 ");

这样试试
------解决方案--------------------
String name = request.getParameter( "id ");
name = new String(id.getBytes( "ISO-8859-1 "), "GB2312 ");


------解决方案--------------------
页面显示乱码用
<%@ page contentType= "text/html; charset=gb2312 " %>

传值乱码用

String name = new String((request.getParameter( "name ")).getBytes( "ISO-8859-1 "), "GBK ");

2楼说的对,只是应该转成GBK
  相关解决方案