我用request.setCharacterEncoding("GB2312");来解决乱码问题,但是为什么会出现下面这样的错误呢?
org.apache.jasper.JasperException: Unable to compile class for JSPAn error occurred at line: 5 in the jsp file: /bookshop/reg.jsp
Generated servlet error:
D:\Tomcat 5.0\work\Catalina\localhost\ch\org\apache\jsp\bookshop\reg_jsp.java:63: cannot resolve symbol
symbol  : method setCharacterEncoding (java.lang.String)
location: interface javax.servlet.http.HttpServletRequest
  request.setCharacterEncoding("GB2312");
               ^
1 error

解决方案 »

  1.   

    你的Tomcat或者其他服务器版本太低了!
      

  2.   

    request.setCharacterEncoding since Servlet 2.3版,仔细查对你的服务器说明文档,看看是否支持2.3
      

  3.   

    不会啊,我一直用的是tomcat5.0。以前运行是不会出错的啊。
      

  4.   

    你看一下classpath,反正这个错,肯定是Servlet版本过低造成的symbol : method setCharacterEncoding (java.lang.String)
    location: interface javax.servlet.http.HttpServletRequestHttpServletRequest(extends ServletRequest)中没有setCharacterEncoding()方法
      

  5.   

    我记得对request设置编码方式是要捕捉异常的,而对response设置gb2312就不用捕捉异常。不知楼主捕了吗?