日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

【thymeleaf 】在 thymeleaf 中使用 shiro 标签

發(fā)布時間:2024/9/19 编程问答 44 豆豆
生活随笔 收集整理的這篇文章主要介紹了 【thymeleaf 】在 thymeleaf 中使用 shiro 标签 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

前言

  • sprint boot 2.3.4.RELEASE

說明

shiro 未提供對 thymeleaf 的支持。第三方項目 thymeleaf-extras-shiro 提供了在 thymeleaf 上使用 shiro 標簽的能力。

A Thymeleaf dialect for Apache Shiro tags.

thymeleaf-extras-shiro

github
https://github.com/theborakompanioni/thymeleaf-extras-shiro

Maven

<dependency><groupId>com.github.theborakompanioni</groupId><artifactId>thymeleaf-extras-shiro</artifactId><!-- 目前最新版為2.0.0 --><version>${thymeleaf-shiro.version}</version> </dependency>

示例

<!DOCTYPE html> <html xmlns:shiro="http://www.pollix.at/thymeleaf/shiro"><head><title>thymeleaf-extras-shiro</title></head><body><p shiro:guest="">Please <a href="login.html">login</a></p><p shiro:authenticated="">Hello, <span shiro:principal=""></span>, how are you today?</p></body></html>

輸出用戶昵稱

<shiro:principal property="nickname" />

還可以這么寫:

<th:block shiro:principal="" property="nickname" />

還可以這么寫:

<span shiro:principal="" property="nickname" />

標簽說明

Apache Shiro tags :

  • https://shiro.apache.org/jsp-tag-library.html
  • https://github.com/apache/shiro/blob/main/web/src/main/resources/META-INF/shiro.tld
標簽含義
shiro:principal當前用戶的登錄信息,用戶名之類
shiro:guest=""驗證是否是游客,即未認證的用戶
shiro:user=""驗證是否是已認證或已記住用戶
shiro:authenticated=""驗證是否是已認證用戶,不包括已記住用戶
shiro:notAuthenticated= “”未認證用戶,但是 已記住用戶
shiro:lacksRole=“admin”表示沒有 admin 角色的用戶
shiro:hasAllRoles=“admin, user1”表示需要同時擁有兩種角色
shiro:hasAnyRoles=“admin, user1”表示 擁有其中一個角色即可
shiro:lacksPermission=“admin:delete”類似于 shiro:lacksRole
shiro:hasAllPermissions=“admin:delete, admin:edit”類似于 shiro:hasAllRoles
shiro:hasAnyPermission=“admin:delete, admin:edit”類似于 hasAnyRoles

總結

以上是生活随笔為你收集整理的【thymeleaf 】在 thymeleaf 中使用 shiro 标签的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。