<%@ page language="java" contentType="text/html; charset=GBK"
pageEncoding="GBK"
%>
String name = request.getParameter("name"); 接收过来的name是汉字
response.sendRedirect("LoginOk.jsp?name="+name);当跳转到LoginOk.jsp页面后,
request.setCharacterEncoding("gbk");
String name = request.getParameter("name");<body>
<center>欢迎你
<%=name %><a href = "index.jsp">首页</a>
</center>
</body>然后就出错了,页面中间是乱码!
LoginOk.jsp的也是<%@ page language="java" contentType="text/html; charset=GBK"
pageEncoding="GBK"%>为什么,急啊,想了老半天了!!
pageEncoding="GBK"
%>
String name = request.getParameter("name"); 接收过来的name是汉字
response.sendRedirect("LoginOk.jsp?name="+name);当跳转到LoginOk.jsp页面后,
request.setCharacterEncoding("gbk");
String name = request.getParameter("name");<body>
<center>欢迎你
<%=name %><a href = "index.jsp">首页</a>
</center>
</body>然后就出错了,页面中间是乱码!
LoginOk.jsp的也是<%@ page language="java" contentType="text/html; charset=GBK"
pageEncoding="GBK"%>为什么,急啊,想了老半天了!!
解决方案 »
- SSH2项目中,注入失败, 在线等,求解……
- 有个小问题,请高手解决一下
- 做J2EE企业业务平台有前途吗?
- 使用websphere编译出错的问题(50分)
- hibernate - ExceptionInInitializerError
- 关于将axis2.war发布在weblogic上面的问题
- struts1.x 的问题
- String对象的replaceAll怎么用?我照写以下的函数,在编译时没出错,但执行时"java.lang.NoSuchMethodError: java.lang.String: method repl
- 用Eclispe+lomboz+JBoss以后还要用EasyStruts么?
- 求EJB文档&代码
- 朋友们帮忙看下这个报错啥意思!!!我无语了!这两天都快疯了!
- 急!!!关于JComboBox的item上下有一片空白区域的问题
Systemm.out.println(name);到控制台看看是不是乱码
url=new String(url.getBytes("ISO-8859-1"),"GBK");
response.sendRedirect(url);
我是这样写的,怎么还出错啊??高手请指教啊,谢谢了,急呀!
String name =new String( request.getParameter("name").getBytes(iso-8859-1),"gbk");
还不行的话将"gbk"改为"gb2312"或"UTF-8"试试
你从数据库取出来时 转码 ISO-8859-1 JSP页面显示时 转码 GBK
ISO-8859-1是个标准 呵呵这样就不会出现乱码了
String name =new String( request.getParameter("name").getBytes(iso-8859-1),"gbk");
用String name = new String(request.getParameter("name").getBytes("ISO8859-1"), "GBK"));
request.setCharacterEncoding("gbk");
String name = request.getParameter("name");//out.print(name);
String pwd = request.getParameter("pwd");//out.print(pwd);
name = new String(name.getBytes("iso-8859-1"),"gbk");
response.sendRedirect("LoginOk.jsp?name="+name);
%>
下面是LoginOk.jsp页面
<%
request.setCharacterEncoding("gbk");
//String name = request.getParameter("name");
String name =new String( request.getParameter("name").getBytes("iso-8859-1"),"gbk");
System.out.println(name);
%>
输出来的是乱码!!
URL是不可以传中文的。URL ENCODER之后,才可以传。。然后再URL DECODER
文章位于:http://blog.csdn.net/auditionlsl/article/details/4208294今天恰巧有人对这篇文章留言,回复过后,我本来是来Java版块提问的。呵呵.提问题去了。
http://blog.csdn.net/wgw335363240/article/details/6059489
要么你在重定向前写上request.setCharacterEncoding("utf-8");
当然取出的时候还是new String(str.getBytes("iso-8859-1"),"utf-8");
这样试下,前提是所有的编码格式一致,楼上的就发现你的编码不一致。