success.jsp页面进不去了啊 错误500 怎么回事 啊 求大神求大神

来源:6-1 登录案例

谁的浮生乱了流年

2017-03-02 20:37

三月 02, 2017 8:31:25 下午 org.apache.catalina.core.StandardWrapperValve invoke

严重: Servlet.service() for servlet [jsp] in context with path [/LoginFilter] threw exception

java.lang.ClassCastException: org.apache.catalina.connector.RequestFacade cannot be cast to javax.servlet.http.HttpServletResponse

at com.imooc.filter.LoginFilter.doFilter(LoginFilter.java:26)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)

at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:218)

at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)

at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)

at org.apache.catalina.core.StandardHostValve.invoke(StandardHostVa



代码跟老师的打得  感觉没毛病啊

@Override

public void doFilter(ServletRequest arg0, ServletResponse arg1,

FilterChain chain) throws IOException, ServletException {

       HttpServletRequest request=  (HttpServletRequest)  arg0;

       HttpServletResponse response=  (HttpServletResponse)  arg0;

   HttpSession session = request.getSession();

   

          if( session.getAttribute("username")!=null){

           chain.doFilter(arg0, arg1);

           

          }else {

         response.sendRedirect("login.jsp");

          }

          

       

       

}

HTTP Status 500 - org.apache.catalina.connector.RequestFacade cannot be cast to javax.servlet.http.HttpServletResponse


写回答 关注

2回答

  • 谁的浮生乱了流年
    2017-03-04 14:18:12

    <filter>                                                        

    <filter-name>CharactorFilter</filter-name>

    <filter-class>com.lyq.CharactorFilter</filter-class>

    <init-param>

    <param-name>encoding</param-name>

    <param-value>UTF-8</param-value>

    </init-param>

    </filter>

    <filter-mapping>

    <filter-name>CharactorFilter</filter-name>

    <url-pattern>/*</url-pattern>

    </filter-mapping>


  • laoLangLoveProgram
    2017-03-03 23:16:51

    你看看是不是在web.xml中过滤器的路径设置的不对,好像跟这个帖子说的类似

    http://stackoverflow.com/questions/35381693/severe-servlet-service-for-servlet-package-in-context-with-path-portal-t

Java Web开发技术应用——过滤器

本课程主要是从实际生活当中的过滤器入手,详细讲解了Java Web过滤器

70492 学习 · 258 问题

查看课程

相似问题