netbeans中中文显示问题!!!
运行1.jsp,在文本框中输入中文字符,希望在页面上输出中文,但是出现乱码。如何解决。请给出详细解决方案。
1.jsp内容如下:
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>    <h1 align="center">查看处罚记录:</h1><br/>
    <form name="form1" action="2.jsp" method="post">
        <table>
            <tr>
                <td align="center">姓名:<input type="text" name="id" size="15"></td> 
            </tr>
            <tr>
                <td align="center"><input type="submit" name="anniu1" value="提交" ></td>
                <td align="center"><input type="reset" name="anniu2" value="取消"></td>
            </tr>
        </table>
    </form>
    
    </body>
</html>2.jsp内容如下:
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%><%
   String id = request.getParameter("id");
   out.write(id);
 %>

解决方案 »

  1.   

    <%@ page contentType="text/plain;charset=gb2312" language="java" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">每个文件头加上上面几行,将你的
    <%@page contentType="text/html"%>
    <%@page pageEncoding="UTF-8"%>
    这些代码换了
      

  2.   

    加一句:
    String id = request.getParameter("id");
    id = new String(id.getBytes("ISO-8859-1"), "utf-8");
      

  3.   


    <%@page contentType="text/html"%>
    <%@page pageEncoding="UTF-8"%>
    改成
    <%@page contentType="text/html; charset=utf-8"%>

     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    这句删了再试下看
      

  4.   

    http://www.matrix.org.cn/resource/article/2005-11-16/J2EE_Multibyte_character_43954.html
      

  5.   

    你因该建一个类,覆盖它的Controller,依次来解决中文问题。