退出实现

修改配置类

修改ShiroConfig类,添加logout filter 对应的url。

红色部分为新增内容。

@Bean
public ShiroFilterChainDefinition shiroFilterChainDefinition() {
    DefaultShiroFilterChainDefinition definition = new DefaultShiroFilterChainDefinition();
    definition.addPathDefinition("/doLogin", "anon");
    definition.addPathDefinition("/logout", "logout");
    definition.addPathDefinition("/**", "authc");
    return definition;
}

  

修改主页面

index.html页面中添加超链接。跳转到/logout后会由shiro内置filter进行拦截。

 

<body>
index.html
<a href="/logout">退出</a>
</body>

  

posted @ 2021-02-01 13:53  巧克力曲奇  阅读(80)  评论(0编辑  收藏  举报