【发布时间】:2014-10-11 16:12:16
【问题描述】:
资源在src/main/resources/static/css或src/main/resources/static/js下,我用的是spring boot,安全的class是:
@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");
}
}
从浏览器访问“/index”时效果很好(可以加载资源),但是如果我取消类中的四行注释,则无法加载资源,这四行表示:
http.authorizeRequests().antMatchers("/", "/index", "/quizStart")
.permitAll().anyRequest().authenticated();
http.formLogin().loginPage("/login").permitAll().and().logout()
.permitAll();
有人可以帮忙吗?提前致谢。
【问题讨论】:
标签: java css spring spring-mvc spring-security