spring boot安全登录重定向到/ contextPath设置

时间:2016-11-07 17:08:55

标签: spring spring-security spring-boot

当没有设置contextPath时,我已经工作了。但是,当我在application.properties中设置server.contextPath时,在登录http://localhost:8080/t2debt_site/login时,页面会重定向到http://localhost:8080/login。可能会发生什么,请帮助!

private static final String[] UNSECURED_RESOURCE_LIST =
        new String[]{"/", "/resources/**", "/static/**", "/css/**", "/webjars/**",
                "/img/**", "/js/**"};

@Override
protected void configure(HttpSecurity http) throws Exception {

    http.authorizeRequests()
            .antMatchers(UNSECURED_RESOURCE_LIST).permitAll()
            .anyRequest().authenticated()
            .and()
            .formLogin()
            .loginPage("/login")
            .defaultSuccessUrl("/index")
            .failureUrl("/login?error")
            .usernameParameter("email")
            .permitAll()
            .and()
            .logout()
            .logoutUrl("/logout")
            .deleteCookies("remember-me")
            .logoutSuccessUrl("/login")
            .permitAll()
            .and()
            .rememberMe();
}

@Override
public void configure(WebSecurity security) {
    //security.ignoring().antMatchers("/css/**","/img/**","/js/**");
    //security.ignoring().antMatchers("/static/**");
    security.ignoring().antMatchers(UNSECURED_RESOURCE_LIST);
    //security.ignoring().antMatchers("/resources/**");
}

0 个答案:

没有答案