Java 应用程序安全后无法访问静态文件
由于某些原因,我无法访问我的CSS和JS文件。发生什么事了Java 应用程序安全后无法访问静态文件,java,css,spring-boot,Java,Css,Spring Boot,由于某些原因,我无法访问我的CSS和JS文件。发生什么事了 @Override protected void configure(HttpSecurity http) throws Exception { http .authorizeRequests() .antMatchers("/", "/home").permitAll() .anyRequest().authenticated()
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/", "/home").permitAll()
.anyRequest().authenticated()
.and()
.formLogin()
.loginPage("/login")
.permitAll()
.and()
.logout()
.permitAll().and().authorizeRequests().antMatchers("/static/**").permitAll();
}
尝试使用:
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/", "/home").permitAll()
.antMatchers("/static/**").permitAll()
.anyRequest().authenticated()
.and()
.formLogin()
.loginPage("/login")
.permitAll()
.and()
.logout()
.permitAll();
}
秩序很重要。所有权限必须在.anyRequest.authenticated之前