当前位置: 代码迷 >> Java Web开发 >> 中文显示!
  详细解决方案

中文显示!

热度:243   发布时间:2006-04-05 18:56:00.0
中文显示!

使用tomcat5.5
我用 dreamweaver 编辑!!


<%@ page contentType="text/html; charset=gb2312"
language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>

<body>
<form id="form1" name="form1" method="post" action="">
<label>tom
<input type="text" name="tom" />
</label>
<label>my
<input type="submit" name="Submit" value="提交" />
</label>
<%
//按课本方法测试!!
//String aa=request.getParameter("tom");
//byte[] b=aa.getBytes("ISO-8859-1");
// aa=new String(b);
//因有错误,再网上搜了两种办法测试!!
//第一种
// String a=request.getParameter("tom");
//String aa=new String(a.getBytes("ISO8859-1")," GB2312");
//第二种
//String aa=request.getParameter("tom");
//byte[] b=aa.getBytes("ISO8859-1");
//aa=new String(b);

%>
<%= aa%>
</form>
</body>
</html>

错误::::
org.apache.jasper.JasperException: Exception in JSP: /Untitled-1.jsp:21

18: <%
19: //按课本方法测试!!
20: String aa=request.getParameter("tom");
21: byte[] b=aa.getBytes("ISO-8859-1");
22: aa=new String(b);
23: //因有错误,再网上搜了两种办法测试!!
24: //第一种


org.apache.jasper.JasperException: Exception in JSP: /Untitled-1.jsp:26

23: //因有错误,再网上搜了两种办法测试!!
24: //第一种
25: String a=request.getParameter("tom");
26: String aa=new String(a.getBytes("ISO8859-1")," GB2312");
27: //第二种
28: //String aa=request.getParameter("tom");
29: //byte[] b=aa.getBytes("ISO8859-1");

org.apache.jasper.JasperException: Exception in JSP: /Untitled-1.jsp:29

26: //String aa=new String(a.getBytes("ISO8859-1")," GB2312");
27: //第二种
28: String aa=request.getParameter("tom");
29: byte[] b=aa.getBytes("ISO8859-1");
30: aa=new String(b);
31:
32: %>

搜索更多相关主题的帖子: html  java  blank  PUBLIC  import  

----------------解决方案--------------------------------------------------------

来个回复的好吗??????????


----------------解决方案--------------------------------------------------------
第一个 是 getBytes("ISO8859-1") ISO后面没有 -

GB2312 前面去掉空格
----------------解决方案--------------------------------------------------------

还是不行,急盼指点!!!!


----------------解决方案--------------------------------------------------------
<%request.setCharacterEncoding("gb2312");%>
在jsp开头加上这个不就可以进行中文传递了马
----------------解决方案--------------------------------------------------------
http://halugen.blog.hexun.com/3558201_d
----------------解决方案--------------------------------------------------------
  相关解决方案