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

前端 未结 7 1462
闹比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 22:51

    For some reason, this did not work for me:

    http.authorizeRequests().antMatchers("/resources/**").permitAll();
    

    I had to add this:

    http.authorizeRequests().antMatchers("/resources/**").permitAll().anyRequest().permitAll();
    

    Also, this line has to be after the code which restrics access.

提交回复
热议问题