关于阻止SpringSecurity拦截SpringBoot静态资源问题

首先感谢一篇博客:https://blog.csdn.net/yali_aini/article/details/83213695

让我了解到springboot访问静态资源,默认有两个默认目录,

一个是  classpath/static 目录 (src/mian/resource)

一个是 ServletContext 根目录下( src/main/webapp)

阻止的方式很简单,在安全控制中心配置即可:

@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = true)
public class SecurityConfig extends WebSecurityConfigurerAdapter {
    @Override
    public void configure(WebSecurity web) throws Exception {
        //解决静态资源被SpringSecurity拦截的问题
        web.ignoring().antMatchers("/static/**");//这样我的webapp下static里的静态资源就不会被拦截了,也就不会导致我的网页的css全部失效了……
    }

}

 

你可能感兴趣的:(java,SpringSecurity)