Spring security does not allow CSS or JS resources to be loaded

前端 未结 7 1454
闹比i
闹比i 2020-11-29 22:45

The resource is under src/main/resources/static/css or src/main/resources/static/js, I\'m using spring boot, and the class of security is:

@Configuration
@En         


        
7条回答
  •  一向
    一向 (楼主)
    2020-11-29 23:02

    I had the same problem and the permitAll() solution didn't work for me. I added the following @Overridemethod to my WebSecurityConfigclass.

    @Override
    public void configure(WebSecurity web) throws Exception {
        web
                .ignoring()
                .antMatchers("/resources/**", "/static/**", "/css/**", "/js/**", "/img/**", "/icon/**");
    }
    

    Good Luck!

提交回复
热议问题