<%@ page contentType="text/html; charset=ISO8859_1" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<!meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head><body>
<p>用户名为:
<%
String s = request.getParameter("txtName");
if (s.compareTo("")==0) s="无";
out.println(s);
%></p>
<p>密码为: <%=request.getParameter("txtKey")%></p>
</body>
</html>
关键是要加上第一行
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<!meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head><body>
<p>用户名为:
<%
String s = request.getParameter("txtName");
if (s.compareTo("")==0) s="无";
out.println(s);
%></p>
<p>密码为: <%=request.getParameter("txtKey")%></p>
</body>
</html>
关键是要加上第一行
public String toChi(String input) {
try {
byte[] bytes = input.getBytes("ISO8859-1");
return new String(bytes);
}catch(Exception ex) {
}
return null;
}
String username=request.getParameter("username");
username=new String(username.getBytes("ISO8859_1"),"GB2312");