实现一个过滤带有.do的地址映射,只有正常登录才能显示success页面的过滤器
web.xml文件
<!--过滤器-->
<filter>
<filter-name>loginfilter</filter-name>
<filter-class>com.amber.filter.LoginFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>loginfilter</filter-name>
<url-pattern>*.do</url-pattern>
</filter-mapping>
LoginFilter.java
package com.amber.filter;
import com.amber.bean.User;
import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
public class LoginFilter implements Filter {
@Override
public void init(FilterConfig filterConfig) throws ServletException{
System.out.println("过滤器初始化");
}
@Override
public void doFilter(ServletReque