spring-security_3_自定义过滤器

配置基本环境

配置基本环境:spring-security基本环境配置
项目目录结构如下图所示:

spring-security_3_自定义过滤器_第1张图片
项目目录结构

实现UsernamePasswordAuthenticationFilter子类

public class MUsernamePasswordAuthenticationFilter extends UsernamePasswordAuthenticationFilter {

    @Override
    public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)
            throws IOException, ServletException {

        for (Object key : req.getParameterMap().keySet()) {
            System.out.println(key + ", " + req.getParameter(key.toString()));
        }

        super.doFilter(req, res, chain);
    }
}

修改security.xml文件




    

        

        

        
    

    
        
            
                
                
            
        
    


    
        
    

    
        
        
        
        
    
    
        
    
    
        
    

发布项目

源码

点击下载源码

你可能感兴趣的:(spring-security_3_自定义过滤器)