<%@ 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>
关键是要加上第一行

解决方案 »

  1.   

    用这个试试看:
    public String toChi(String input) {
    try {
    byte[] bytes = input.getBytes("ISO8859-1");
    return new String(bytes);
    }catch(Exception ex) {
    }
    return null;
    }
      

  2.   

    对与从提交页面中取得的参数要进行中文转码处理,加上下面两句就可以了,例如:
    String username=request.getParameter("username");
    username=new String(username.getBytes("ISO8859_1"),"GB2312");