谁的浮生乱了流年
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
<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>
你看看是不是在web.xml中过滤器的路径设置的不对,好像跟这个帖子说的类似
Java Web开发技术应用——过滤器
70492 学习 · 258 问题
相似问题