java - when spring security enabled, resouces(css or js) can't be loaded -


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

@configuration @enablewebmvcsecurity @enableglobalauthentication public class websecurityconfig extends websecurityconfigureradapter {      @override     protected void configure(httpsecurity http) throws exception { //      http.authorizerequests().antmatchers("/", "/index", "/quizstart") //              .permitall().anyrequest().authenticated(); //      http.formlogin().loginpage("/login").permitall().and().logout() //              .permitall();     }      @override     protected void configure(authenticationmanagerbuilder auth)             throws exception {         auth.inmemoryauthentication().withuser("test").password("test")                 .roles("user");     } } 

it works (resources can loaded) when access "/index" browser, however, if uncomment 4 lines in class, resources can not loaded, 4 lines means:

    http.authorizerequests().antmatchers("/", "/index", "/quizstart")             .permitall().anyrequest().authenticated();     http.formlogin().loginpage("/login").permitall().and().logout()             .permitall(); 

could ? in advance.

you want make sure have directory containing items set permitall.

here's excerpt spring security context file. under resources directory, have js, css, , images folders given permissions line.

<security:intercept-url pattern="/resources/**" access="permitall" /> 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -