我已经在Resource下添加了css和js,然后添加了static文件夹。当我访问路径"forgotpassword“时,我所有的静态资源都被正确加载。enter image description here
但是,当我尝试访问相同的路径,但这次使用了一个斜杠"forgotpassword/“时,我所有的静态资源都不会加载。我收到状态404 not found enter image description here
这是我的安全配置
@Configuration
@EnableGlobalMethodSecurity(prePostEnabled = true)
@Order(-20)
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
@Qualifier("customUserDetailsService")
UserDetailsService userDetailsService;
static private Logger logger = LoggerFactory.getLogger(Oauth2AuthserverApplication.class);
@Bean
public PasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();
}
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth
.userDetailsService(userDetailsService)
.passwordEncoder(passwordEncoder());
}
@Override
@Bean
public AuthenticationManager authenticationManagerBean() throws Exception {
return super.authenticationManagerBean();
}
@Override
protected void configure(HttpSecurity http) throws Exception {
// @formatter:off
http
.authorizeRequests()
.antMatchers("/resources/**", "/forgotpassword/**")
.permitAll()
.anyRequest().authenticated()
.and()
.formLogin()
.loginPage("/login")
.permitAll()
.and()
.requestMatchers().antMatchers("/forgotpassword/**", "/login", "/oauth/authorize", "/oauth/confirm_access");
// @formatter:on
}
}
发布于 2017-12-06 22:01:28
对于css和js th:src="@{/js/jquery/dist/jquery.min.js}"
,这是我必须做的th:href="@{/css/Default/css/style.css}"
。
https://stackoverflow.com/questions/38998387
复制相似问题