1.首先第一步導入依賴
<dependency> <groupId>com.github.theborakompanioni</groupId> <artifactId>thymeleaf-extras-shiro</artifactId> <version>1.2.1</version> </dependency>
2.在配置shiro權限的方法內加入
@Bean public ShiroDialect shiroDialect() { return new ShiroDialect(); }
3.ftl頁面中引入命名空間
<html lang="zh_CN" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
4.ftl頁面中使用標簽
<@shiro.hasRole name="merchants"> <div> 我有這個角色哦! </div> </@shiro.hasRole>
總結
以上所述是小編給大家介紹的springboot 在ftl頁面上使用shiro標簽的實例代碼,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對VeVb武林網網站的支持!
新聞熱點
疑難解答
圖片精選