[英]Thymeleaf incorrectly loads static files
在 spring security 4.x 中 - spring security 中的資源是permitAll
。
在 spring security 5.x 中 - 您應該手動配置它。
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests().antMatchers("/css/**", "/js/**").permitAll()
}
請嘗試檢查以下幾點:
1.ResourceHandler有css位置
class WebConfig implements WebMvcConfigurer {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/css/**")
.addResourceLocations("classpath:/static/css/");
}
...
}
2.在spring-security規則中排除*.css
class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
public void configure(WebSecurity web) throws Exception {
web.ignoring().antMatchers(
"/css/\**",
"/js/\**",
"/img/\**",
...
);
}
...
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.