【发布时间】:2018-06-29 08:16:20
【问题描述】:
我正在尝试访问“src\main\resources\static”文件夹中的内容,但在 chrome 的检查窗口中出现 401 错误。
在“静态”文件夹中,我有一个名为“assets”的子文件夹,结构有点像这样。
assets/css/**
assets/js/**
assets/fonts/**
assets/image/**
assets/css/boostrap/**
这是我的WebMvcConfigurerAdapter 课程
@Configuration
public class OAuthWebFormConfiguration extends WebMvcConfigurerAdapter {
@Override
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/login").setViewName("login");
registry.addViewController("/oauth/confirm_access").setViewName("authorize");
}
@Configuration
@Order(-20)
protected static class LoginConfig extends WebSecurityConfigurerAdapter {
@Autowired
private CustomAuthenticationManager customAuthenticationManager;
@Override
protected void configure(HttpSecurity http) throws Exception {
http.formLogin().loginPage("/login").permitAll()
.and()
.requestMatchers()
.antMatchers("/login", "/oauth/authorize", "/oauth/confirm_access")//,"/resources/**", "/assets/**"
.and()
.authorizeRequests()
.anyRequest()
.authenticated();
}
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.parentAuthenticationManager(customAuthenticationManager);
}
}
}
【问题讨论】:
-
你点击什么网址来访问它们??
-
@KarthikR,我正在尝试访问我的 Auth-Server 的自定义登录页面。可以在“server:port/app/login”访问
-
你必须像这样点击 URL:
http://<SERVER>:<PORT>/app/assets/image/sunrise.jpg因为static/**在 spring boot 中默认添加
标签: java spring-boot spring-security