我正在尝试执行当用户离开网站 30 分钟以上时自动将用户重定向到登录页面的任务(shiro 认为他已注销)。
根据这个页面 https://stormpath.com/blog/whats-new-apache-shiro-12/
我需要在ini中使用logout.redirectUrl
我尝试过,但没有成功实现此功能
这是我的ini
[main]
jdbcRealm=org.apache.shiro.realm.jdbc.JdbcRealm
jdbcRealm.authenticationQuery = SELECT password from users where user_name = ?
jdbcRealm.userRolesQuery = select role_name from users_roles where user_name = (select user_name FROM users WHERE user_name = ?)
ds = org.postgresql.ds.PGSimpleDataSource
ds.serverName =localhost
ds.user = postgres
ds.password = 123456
ds.databaseName = example
jdbcRealm.dataSource= $ds
authc.loginUrl = /faces/login.xhtml
user.loginUrl = /faces/login.xhtml
logout.redirectUrl = /faces/login.xhtml
multipleroles = com.example.util.MultipleRolesAuthorizationFilter
[urls]
/faces/login.xhtml = authc
/faces/logout = logout
/faces/authorized/** = user, multipleroles["admin,guest"]
/faces/guest/** = user, multipleroles["admin,guest"]
/faces/admin/** = user, roles[admin]
最佳答案
这听起来更像是您使用某种 javascript/push 框架所做的事情。当用户在后端注销时,不会向浏览器发送任何内容,因此浏览器无法知道需要重定向,直到用户单击某些内容。
所以这更多的是前端/推送/javascript 问题,而不是 shiro 问题。
关于java - 将用户重定向到 shiro 上的默认 ‘after logout’ 页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25708706/