输入http://localhost:8080/admin/login,样式无法加载
来源:5-2 后台登录功能实现
慕盖茨0002275
2020-12-10
前端代码直接用源代码的没有动,后端代码再最后,
输入http://localhost:8080/admin/login,显示如下错误
Refused to apply style from 'http://localhost:8080/static/css/admin/login-style.css' because its MIME type ('application/json') is not a supported stylesheet MIME type, and strict MIME checking is enabled.
样式加载不了

@EnableWebSecurity
@EnableGlobalMethodSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
// 资源访问权限
http.authorizeRequests()
.antMatchers("/admin/login").permitAll() // 管理员登陆入库
.antMatchers("/static/**").permitAll() // 静态资源
.antMatchers("/user/login").permitAll() // 用户登陆入口
.antMatchers("/admin/**").hasRole("ADMIN")
.antMatchers("/user/**").hasAnyRole("ADMIN", "USER")
.antMatchers("/api/user/**").hasAnyRole("ADMIN", "USER")
.and()
.formLogin()
.loginProcessingUrl("/login")
.and();
http.csrf().disable();
http.headers().frameOptions().sameOrigin();
}
}
写回答
1回答
-
瓦力老师
2021-01-05
亲,可以尝试使用相对路径,如:../static/css/login.css
10
相似问题