日期:2014-05-18  浏览次数:20749 次

关于Servlet不能显示中文!急呀、急呀、急呀、急呀、……
我帮看看我的代码为什么提交表单的时候返回的是一堆问号呀???
public   void   doGet(HttpServletRequest   request,   HttpServletResponse   response)   throws
                        ServletException,   IOException   {
               
                request.setCharacterEncoding( "GB2312 ");
                response.setContentType( "text/html;   charset=GB2312 ");

                PrintWriter   out   =   response.getWriter();

              Enumeration   em=   request.getParameterNames();
              String   string,br= " <br> ";
              out.print( "下面显示你输入的信息 "+br);
              while(em.hasMoreElements())
              {
                      string=em.nextElement().toString();
                      out.print( "你输入的内容是--> "+request.getParameter(string)+br);

              }


        }
请帮看看把谢谢了


------解决方案--------------------
中文问题见:http://www.java99.com/?m=ViewArticle&id=250
------解决方案--------------------
建议你到网上下一个过滤器就可以解决所有的中文问题了,包括文件上传时中文文件名的问题都能解决了
------解决方案--------------------
查看提交页的编码格式,可能是两个页面的编码不匹配。
------解决方案--------------------
request.getParameterNames()因该返回String[]把。
------解决方案--------------------
过滤器是个不错的选择
------解决方案--------------------
JSP页面设置为GBK内码

提交方式设置为POST提交