资源在src/main/resources/static/css或src/main/resources/static/js下,我正在使用spring boot,安全类是:
@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");
}
}
Run Code Online (Sandbox Code Playgroud)
当我从浏览器访问"/ index"时它运行良好(可以加载资源),但是,如果我取消注释类中的四行,则无法加载资源,这四行意味着:
http.authorizeRequests().antMatchers("/", "/index", "/quizStart")
.permitAll().anyRequest().authenticated();
http.formLogin().loginPage("/login").permitAll().and().logout()
.permitAll();
Run Code Online (Sandbox Code Playgroud)
任何人都可以帮忙吗?提前致谢.