Spring Security 自定义登陆页面
新建Spring Security配置文件 SecurityConfig, 对SecurityConfig 继承WebSecurityConfigurerAdapter ,重写configure 方法。
如下:
@Configuration
@Slf4j
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter{
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.getDefaultUserDetailsService();
}
@Override
public void configure(WebSecurity web) throws Exception {
web.ignoring().antMatchers("/js/**", "/css/**", "/images/**", "/html/**");
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
.anyRequest().authenticated()
.and()
.formLogin()
.loginPage("/html/login.html")
.loginProcessingUrl("/login")
.permitAll()
.and()
.csrf().disable();
}
如图: