大家好!
       我在写了个简单的jsp页面,里面有个提交表单,提交到servlet中显示一下中文,但为什么都是乱码啊?  请给予解决,谢谢! 具体代码如下:// jsp
<%@ page contentType="text/html; charset=GBK" %>
<%
//response.setCharacterEncoding("gb2312");
//request.setCharacterEncoding("gb2312");
%>
<html>
<head>
<title>
jsp1
</title>
</head>
<body>
<form action="./servlet1">
<table>
<tr>
<td><input type="text" name="name"><input type="submit" value="sdsdsd"></td>
</tr>
</table>
</form>
</body>
</html>
----------------------------------------------------
//servlet1的doGet方法public void doGet(HttpServletRequest request, HttpServletResponse response) throws
            ServletException, IOException {
        
//        response.setCharacterEncoding("gb2312");
//        request.setCharacterEncoding("gb2312");        response.setContentType("text/html; charset=GBK");
        PrintWriter out = response.getWriter();
        String name = new String(request.getParameter("name").getBytes("ISO-8559-1"),"gbk");
        out.println("<html>");
        out.println("<head><title>Servlet1</title></head>");
        out.println("<body bgcolor=\"#ffffff\">");
        out.println("<p>" + name + "</p>");
        out.println("</body>");
        out.println("</html>");
        out.close();
    }我把在论坛里说的方法都用了,怎么还显示乱码呀! 请帮帮忙,解决后保证给分!

解决方案 »

  1.   

    转码,可以写一个filter,关于例子可以看下面的帖子中我的回复http://community.csdn.net/Expert/TopicView3.asp?id=5460412
      

  2.   

    我加了filter  怎么还是不管用啊!  大侠   也设了映射了
      

  3.   

    问题已经解决,JSP中的Method方法是POST时,在servlet中设置request.setCharacterEncoding("gb2312");
    就可以了。 结贴……………………