admin管理员组

文章数量:1641944

spring web项目 加入@WebFilter类未生效,研究了下是web.xml头未配置正确

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun/xml/ns/javaee" xmlns:xsi="http://www.w3/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun/xml/ns/javaee http://java.sun/xml/ns/javaee/web-app_3_0.xsd" version="3.0">

 过滤类如下

@Service
@WebFilter(filterName = "CommonFilter", urlPatterns = "/*")
public class CommonFilter implements Filter {

    private Logger logger = LoggerFactory.getLogger(CommonFilter.class);

    public void init(FilterConfig filterConfig) throws ServletException {
        logger.info("================= init xxxxx ====================");
       // WebApplicationContext webApplicationContext = ContextLoader.getCurrentWebApplicationContext();
    }

    /**
     * 通用的总过滤器
     */
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
        chain.doFilter(request, response);
    }

    public void destroy() {
        logger.info("======destroy=comment=====");
    }


}

 

本文标签: 解决办法WebFilter