springSecurity5 use:
. http.formLogin () loginPage ( "/ login");
given below:
Request permission to add springsucurity5 need to define yourself:
Failure code as follows:
public class MySecurityConfig extends WebSecurityConfigurerAdapter { @Override protected void the configure (HttpSecurity HTTP) throws Exception { // authorization rule customization request http.authorizeRequests (). antMatchers ( "/" ) .permitAll () .antMatchers ( "/ the Manage / **"). hasRole ( "the Manage" ) .antMatchers("/view/**").hasRole("view") .antMatchers("/db/**").hasRole("db").anyRequest().authenticated(); http.formLogin().loginPage("/login");
After correcting code is as follows:
public class MySecurityConfig extends WebSecurityConfigurerAdapter { @Override protected void configure(HttpSecurity http) throws Exception { http.authorizeRequests().antMatchers("/").permitAll() .antMatchers("/login").permitAll() .antMatchers("/manage/**").hasRole("manage") .antMatchers("/view/**").hasRole("view") .antMatchers("/db/**").hasRole("db").anyRequest().authenticated(); //http.formLogin(); http.formLogin().loginPage("/login");