首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Spring boot安全、oauth2和胸腺叶静态资源找不到

Spring boot安全、oauth2和胸腺叶静态资源找不到
EN

Stack Overflow用户
提问于 2016-08-17 21:42:39
回答 1查看 717关注 0票数 1

我已经在Resource下添加了css和js,然后添加了static文件夹。当我访问路径"forgotpassword“时,我所有的静态资源都被正确加载。enter image description here

但是,当我尝试访问相同的路径,但这次使用了一个斜杠"forgotpassword/“时,我所有的静态资源都不会加载。我收到状态404 not found enter image description here

这是我的安全配置

代码语言:javascript
运行
复制
@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
    }

}
EN

回答 1

Stack Overflow用户

发布于 2017-12-06 22:01:28

对于css和js th:src="@{/js/jquery/dist/jquery.min.js}",这是我必须做的th:href="@{/css/Default/css/style.css}"

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38998387

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档