Shiro自定义登录页面配置,Shiro默认登录页面

 

================================

©Copyright 蕃薯耀 2022-04-06

https://www.cnblogs.com/fanshuyao/

 

一、Shiro默认登录页面

Shiro默认登录页面是根路径的jsp页面:

/login.jsp

 

二、Shiro自定义登录页面

 

方式一:application.properties配置


在application.properties文件配置shiro.loginUrl

shiro.loginUrl=/login

 

方式二:在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;
    }

 

注意:要测试登录拦截跳转登录页面,先配置登录页面不拦截,和拦截其它页面需要拦截

filterChainDefinitionMap.put("/login", "anon");
filterChainDefinitionMap.put("/**", "authc");

 

 

 

配置未授权跳转的页面

shiroFilterFactoryBean.setUnauthorizedUrl("/error");

 

 

配置登录成功跳转的页面

shiroFilterFactoryBean.setSuccessUrl("/mainIndex");

 

 

(时间宝贵,分享不易,捐赠回馈,^_^)

 

================================

©Copyright 蕃薯耀 2022-04-06

https://www.cnblogs.com/fanshuyao/

 
posted @ 2022-04-06 11:30  蕃薯耀  阅读(27)  评论(1编辑  收藏  举报