问答详情
源自:6-1 登录案例

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

三月 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


提问者:谁的浮生乱了流年 2017-03-02 20:37

个回答

  • 谁的浮生乱了流年
    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