更新時(shí)間:2022-02-08 10:31:48 來(lái)源:動(dòng)力節(jié)點(diǎn) 瀏覽987次
Shiro 為 JSP 頁(yè)面的權(quán)限控制提供了一個(gè) JSTL 標(biāo)簽:
1.GUEST標(biāo)簽:用戶無(wú)身份驗(yàn)證信息顯示,相當(dāng)于旅游模式
<shiro:guest><br>Visitor mode, please log in: <a href="..."> login </A><br><shiro:guest>
2.用戶標(biāo)簽:用戶已經(jīng)識(shí)別登錄后顯示/記住我
<shiro:user><br>Congratulations <shiro: principal /> has been successfully logged in!<br><shiro:user>
3.Authenticated Tags:用戶已驗(yàn)證通過(guò),不記得我登陸
<shiro:authenticated>
恭喜<shiro:principal/>驗(yàn)證
<shiro:authenticated>
4.Notauthenticated:用戶沒(méi)有認(rèn)證,沒(méi)有調(diào)用Subject.login
包括記住我登錄也屬于未認(rèn)證
<shiro:notAuthenticated>
沒(méi)有認(rèn)證(包括“記住我” )
</shiro:notAuthenticated>
5.principal :顯示用戶身份信息Subject.getPrincipal(),主principal,默認(rèn)為PRIMARY PRINCIPAL
<shiro:principal property= "用戶名" />
6.HASROLLE Tags: If the current Subject has a character will display content in a body
<shiro:hashRole name = " admin " >
user[ <shiro:principal/> ] 有一個(gè)角色 admin
</shiro:hashRole>
7.hasanyroles Tags: If Subject has anyOneCharacter(Relationship) Will display content in the body body
<shiro:hasAnyRoles name = " admin,user " >
user[ <shiro:pricipal/> ] 擁有角色 admin 或 user
</shiro:hasAnyRoles>
8.Lacksrole: If the current Subjec does not have a character, the contents of the body will be displayed.
<shiro:lacksRole name = " admin " >
user[ <shiro:pricipal/> ] 沒(méi)有角色 admin </br>
</shiro:lacksRole>
9.Hashpermission: If the currentSubjectPermissionShow body content
<shiro:hashPermission name = " user:create " >
user[ <shiro:pricipal/> ] 擁有特權(quán)用戶:Create
</shiro:hashPermission>
10.lackspermission: If the current Subject does not have permission, a body content will be displayed
<shiro:lacksPermission name = " org:create " >
user[ <shiro:pricipal/> ] 無(wú)權(quán)限 Org: CREATE
</shiro:lacksPermission>
在 list.jsp 文件中:
<正文>
列表。
歡迎:<shiro:principal></shiro:principal>
<shiro:hasRole name="admin"> <a href=" admin.jsp "
> TO Admin </a>
</shiro:hasRole>
<shiro:hasRole name="user"> <a href=" user.jsp "
> TO User </a>
</shiro:hasRole>
<a href=" shiro/logout " >注銷</a>
</正文>
使用用戶登錄:
使用管理員登錄:
以上就是關(guān)于“Shiro標(biāo)簽的用法示例”的介紹,大家如果想了解更多相關(guān)知識(shí),不妨來(lái)關(guān)注一下動(dòng)力節(jié)點(diǎn)的Shiro視頻教程,里面的課程內(nèi)容細(xì)致全面,由淺到深,適合沒(méi)有基礎(chǔ)的小白學(xué)習(xí),希望對(duì)大家能夠有所幫助。
0基礎(chǔ) 0學(xué)費(fèi) 15天面授
有基礎(chǔ) 直達(dá)就業(yè)
業(yè)余時(shí)間 高薪轉(zhuǎn)行
工作1~3年,加薪神器
工作3~5年,晉升架構(gòu)
提交申請(qǐng)后,顧問(wèn)老師會(huì)電話與您溝通安排學(xué)習(xí)