jsp乱码问题,解决就结贴给分,谢谢! 在b.jsp里面把<%@ page contentType="text/html; charset=gb2312" %>去掉 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 对某些版本的Tomcat,如4.1.29,request.setCharacterEncoding("GB2312")对GET方式提交的信息无效(POST方式可以),必须得用getBytes(...)转换,如果你不幸撞到了这种版本,方法两个,一个是用getBytes强制转换,再就是换一个Tomcat 在你任务的每个部分.比如jsp/servlet/db之中的GB2312 都保持一致!看看看ok嘛? 不是,这个不涉及servlet,只是在页面之间的数据传递 把<%@ page contentType="text/html; charset=gb2312" %>改为<%@ page contentType="text/html;charset=8859_1"%>试一下这句request.setCharacterEncoding("gb2312");也去掉可以肯定试charset的设置问题,从这里着手吧 String tempclass1 = new String(tempclass.getBytes("ISO8859-1"));out.print(tempclass1);把要显示的加上上面的东西。 这是我参考别人的,你可以参考一下:jsp2.jsp:<%@ page contentType="text/html; charset=GB2312" %><%@ page import="java.io.UnsupportedEncodingException"%><%@ page import="java.net.URLEncoder" %><html><head><title>jsp2</title></head><body bgcolor="#ffffff"><%String name = "中文";String encodedName = null;try { encodedName = URLEncoder.encode(name, "UTF-8"); System.out.println("encodedName charset:");} catch (UnsupportedEncodingException uex) { System.out.println("Got UnsupportedEncodingException : " + uex.toString());}%><a href="test2.jsp?name=<%=encodedName%>"><%=name%></a></body></html>test2.jsp<%@ page contentType="text/html; charset=GBK" %><%@ page import="java.io.UnsupportedEncodingException"%><html><head><title>test2</title></head><body bgcolor="#ffffff"><h1><%String name = null;try { name = new String(request.getParameter("name").getBytes("ISO-8859-1"), "UTF-8"); System.out.println("name="+name);} catch (UnsupportedEncodingException uex) { System.out.println("Got UnsupportedEncodingException : " + uex.toString());}%></h1></body></html> 在b.jsp里面把<%@ page contentType="text/html; charset=gb2312" %>去掉 java 求一算法 容器内可以存放基本类型的数值吗? 我这Socket程序怎么老是有异常,救命 HTML的问题 各位有没有统计过,在不同的操作系统上加载虚拟机需要几秒钟? java如何压缩解压缩lzh?有开源代码没有?有算法也行。在线等待,期待您的关注! 在书本上看了两条注意,经过测试发现是错的。 如何关闭URLConnection对像啊? faint!又有问题了!!高手帮忙!!! 有关applet的一个小问题,但很急切知道答案. 求教:java Applet中如何调用java script 有没有快捷的方式对字符串进行格式化?????
看看看ok嘛?
改为<%@ page contentType="text/html;charset=8859_1"%>
试一下
这句request.setCharacterEncoding("gb2312");也去掉可以肯定试charset的设置问题,从这里着手吧
out.print(tempclass1);
把要显示的加上上面的东西。
jsp2.jsp:
<%@ page contentType="text/html; charset=GB2312" %>
<%@ page import="java.io.UnsupportedEncodingException"%>
<%@ page import="java.net.URLEncoder" %>
<html>
<head>
<title>
jsp2
</title>
</head>
<body bgcolor="#ffffff">
<%String name = "中文";
String encodedName = null;
try {
encodedName = URLEncoder.encode(name, "UTF-8");
System.out.println("encodedName charset:");
} catch (UnsupportedEncodingException uex) {
System.out.println("Got UnsupportedEncodingException : " + uex.toString());
}
%>
<a href="test2.jsp?name=<%=encodedName%>"><%=name%></a>
</body>
</html>
test2.jsp
<%@ page contentType="text/html; charset=GBK" %>
<%@ page import="java.io.UnsupportedEncodingException"%><html>
<head>
<title>
test2
</title>
</head>
<body bgcolor="#ffffff">
<h1>
<%String name = null;
try {
name = new String(request.getParameter("name").getBytes("ISO-8859-1"), "UTF-8");
System.out.println("name="+name);
} catch (UnsupportedEncodingException uex) {
System.out.println("Got UnsupportedEncodingException : " + uex.toString());
}%>
</h1>
</body>
</html>
去掉