使用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: %>