================================
©Copyright Sweet Potato Yao2022-04-06
Sweet Potato Yao's Blog - CSDN Blog
1. Shiro default login page
The default login page of Shiro is the jsp page of the root path:
/login.jsp
2. Shiro custom login page
Method 1: application.properties configuration
Configure shiro.loginUrl in the application.properties file
shiro.loginUrl=/login
Method 2: Configure in ShiroFilterChainDefinition
shiroFilterFactoryBean.setLoginUrl("/login");
@Bean
public ShiroFilterFactoryBean shiroFilterFactoryBean () {
ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean();
shiroFilterFactoryBean.setLoginUrl("/login");
//shiroFilterFactoryBean.setSuccessUrl("/mainIndex");
shiroFilterFactoryBean.setUnauthorizedUrl("/error");
shiroFilterFactoryBean.setSecurityManager(defaultWebSecurityManager());
return shiroFilterFactoryBean;
}
Note: To test the login interception and jump to the login page, first configure the login page not to intercept, and intercept other pages that need to be intercepted
filterChainDefinitionMap.put("/login", "anon");
filterChainDefinitionMap.put("/**", "authc");
Configure unauthorized pages to jump to
shiroFilterFactoryBean.setUnauthorizedUrl("/error");
Configure the page to which the login is successfully redirected
shiroFilterFactoryBean.setSuccessUrl("/mainIndex");
(Time is precious, sharing is not easy, donate and give back, ^_^)
================================
©Copyright Sweet Potato Yao2022-04-06