protected void configure(HttpSecurity http) throws Exception {
// http.httpBasic()
// .and().csrf().disable()
// .authorizeRequests()
// .antMatchers("/","/login").permitAll()
// .anyRequest().authenticated()
// .and()
// .formLogin()
// //.loginPage("/login")
// .permitAll()
// .and()
// .logout().permitAll();
// 硬编码形式白名单
http
.authorizeRequests()
.antMatchers(
StaticParams.PATHREGX.API,
StaticParams.PATHREGX.CSS,
StaticParams.PATHREGX.JS,
StaticParams.PATHREGX.IMG).permitAll()//允许用户任意访问
.anyRequest().authenticated()//其余所有请求都需要认证后才可访问
.and()
.formLogin()
//.loginPage("/login/login.do") //这里不适用自定义的页面,使用springsecurity 默认提供的页面
// .defaultSuccessUrl("/hello2")
.permitAll();//允许用户任意访问
http.csrf().disable();
}