jsp地址栏传参数乱码问题
第一种:一般的超链接传参数<a href="http://localhost:8080/index.jsp?name=name>手动提交 </a>
那么,在index.jsp页面接收参数时要用
<%= newString(request.getParameter("empcode").getBytes("iso-8859-1"),"utf-8")%>
接收,当然你的项目必须统一编码格式,此例为utf-8
第二种:自动刷新页面用到的传参数
首先,获取action中传来的 参数
<%
String str=request.getParameter("name");
byte b[]=str.getBytes("UTF-8");
str=new String(b,"iso-8859-1");
%>
<%
response.setHeader("refresh","1;URL=index.jsp?name="+str);
%>
在index.jsp页面接收参数时和第一种方式相同
测试过,可以实现。
注意:一定要统一格式编码,具体方法下次补上 JSP 乱码 UTF-8 测试
补充:Java , Web 开发