我也遇到过和你一样的问题,高手们也都给了很诚恳的建议,和你用的一样
可是和你一样,我也试了,就是不行
于是乎
我这样:在两个页面里,不用<%@ page contentType = "text/html;charset=gb2312"%>(一定不要有)
在<head></head>中加上<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
String p = request.getParameter("中文");
不要进行转换,试试吧
我这样子成功了,如果这样你也不行,希望你快点找到正确的答案
可是和你一样,我也试了,就是不行
于是乎
我这样:在两个页面里,不用<%@ page contentType = "text/html;charset=gb2312"%>(一定不要有)
在<head></head>中加上<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
String p = request.getParameter("中文");
不要进行转换,试试吧
我这样子成功了,如果这样你也不行,希望你快点找到正确的答案
...
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
...
<form method=post action=addstudent.jsp name=form >
...
<input type=submit class=p1 name=Submit value=" 确 认 " onclick="return sub()" >
<input type=button class=p1 value=" 返 回 " style="cursor:hand;">
...addstudent.jsp:
...
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
...
<%
// get the parameters of a student from studnet.jspString sNumber = request.getParameter( "Snumber");
String sName = request.getParameter("Sname");
String sSex = request.getParameter("Ssex");
int sAge = Integer.parseInt( request.getParameter("Sage") );
String specialty = request.getParameter("Specialty");
String college = request.getParameter("College");
String sclass = request.getParameter("Class");
String grade = request.getParameter("Grade");
%>
...显示一下,我的ok。呵呵
xml文件中
<?xml version="1.0" encoding="GB2312" ?>
<form accept-charset="gb2312">
xsl中
<meta http-equiv="Content-Type" content="text/html; charset=GB2312" />
<xsl:output encoding="gb2312"/>
jsp中
<%@ page language ="java" session ="true" contentType="text/xml;charset=gb2312"%>
uname="中文乱码";
byte gb[] = uname.getBytes("ISO8859_1");
uname = new String(gb, "gb2312");字符集,真让人吐血;java,真让人又爱又恨!