Mad*_*aur 5 java shiro jsf-2.2
我一直在尝试为shiro.ini文件的url部分为Web应用程序分配不同的未授权URL,但似乎我无法做到.Below是我尝试过的代码.
shiro.ini文件
[main]
authc1 = org.apache.shiro.web.filter.authc.FormAuthenticationFilter
authc2 = org.apache.shiro.web.filter.authc.FormAuthenticationFilter
authc1.loginUrl = /login.xhtml
authc2.loginUrl = /secLoginPage.xhtml
[urls]
/login.xhtml = authc1
/secLoginPage.xhtml = authc2
/testapp/** = authc1, roles[admin,unauthorizedUrl=/adminAuthPage.xhtml]
/userfld/**=authc2,roles[user,unauthorizedUrl=/abortPage.xhtml]
/** = authc1
/** = authc2
Run Code Online (Sandbox Code Playgroud)
登录到应用程序后,它会重定向到授权页面并出现错误Error 401: SRVE0295E: Error reported: 401.
添加后发生此错误unauthorizedUrl=/adminAuthPage.xhtml.如果代码中有任何错误,请建议.
您可以创建一个未经授权的页面,该页面现在充当其页面重定向到所需页面的入口点吗?
403.jsp
<shiro:hasRole name="admin">
<c:redirect url="adminAuthPage.xhtml"/>
</shiro:hasRole>
<shiro:hasRole name="user">
<c:redirect url="abortPage.xhtml"/>
</shiro:hasRole>
Run Code Online (Sandbox Code Playgroud)
或者更好,如果您只想管理员有另一个页面
<shiro:hasRole name="admin">
<c:redirect url="adminAuthPage.xhtml"/>
</shiro:hasRole>
<shiro:lacksRole name="admin">
<c:redirect url="abortPage.xhtml"/>
</shiro:lacksRole>
Run Code Online (Sandbox Code Playgroud)