[英]accessDeniedPage redirect rather than just display the appropriate page RSS feed
I have 2 user roles - user
and admin
, if I go to a url where any authentication is needed and I am not authenticated - I get redirected to the login page, which is fine. 我有2个用户角色 -
user
和admin
,如果我去一个需要任何身份验证的URL并且我没有经过身份验证 - 我被重定向到登录页面,这很好。
However, if I am logged in as user
, and I try to access an admin
only page, I get the home page displayed, but the url stays the same. 但是,如果我以
user
身份登录,并且我尝试访问仅限admin
页面,则会显示主页,但网址保持不变。 I want to actually redirect to the home page rather than just display it. 我想实际重定向到主页而不是只显示它。
...
.and()
.exceptionHandling()
.accessDeniedPage("/")
So is there any way to make the accessDeniedPage
method redirect, because as I said the home page is displayed but the url does not change. 那么,有没有办法让
accessDeniedPage
方法重定向,因为我说的是显示在主页上,但URL不会改变。
May be try following? 可以尝试以下?
.and()
.exceptionHandling()
.accessDeniedPage("redirect:/")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.