【发布时间】:2016-05-04 06:20:47
【问题描述】:
我在 angularjs 应用程序上工作,并尝试使用 Spring boot 提供静态资源(我的前端)。
- 这是hash文件夹的内容
我的 spring 安全配置如下所示:
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.exceptionHandling()
.authenticationEntryPoint(myEntryPoint());
http
.authorizeRequests()
.antMatchers("/__hash__/**").permitAll()
.antMatchers("/views/**").permitAll()
.antMatchers("/index.html").permitAll()
.antMatchers("/api/**").authenticated()
.antMatchers("/**").permitAll();
http // login configuration
.addFilterAfter(springSecurityFilter(), BasicAuthenticationFilter.class);
/*http
.authorizeRequests()
.anyRequest().authenticated();*/
http //logout configuration
.logout()
.logoutSuccessHandler(logoutHandler());
http.csrf().disable();
}
用于提供静态内容的配置弹簧:
@Configuration
public class MyContentConfig extends WebMvcConfigurerAdapter {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry
.addResourceHandler("/**")
.addResourceLocations("file:///" + "c:/front/") ;
}
@Override
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/").setViewName("forward:/index.html");
}
}
身份验证后,我得到了 index.html 页面,但没有 css 样式,也没有 js。
当我尝试使用此 URL“https://localhost:9999/hash/styles.min.css”访问 css 时,我收到此错误:
There was an unexpected error (type=Not Acceptable, status=406).
Could not find acceptable representation
【问题讨论】:
-
您正在使用 HTTPS 访问您的服务器资源.. 您的 .properties中是否有有效的 SSL 配置> 文件?
-
是的。我已将 tomcat 配置为使用 SSL
-
您尝试过使用 HTTP 吗?
标签: java angularjs spring spring-security gulp