spring mvc + shiro +thymeleaf 扩展使用shiro tags页面标签

先看官方说明:
Apache Shiro provides a Subject-aware JSP/GSP tag library that allows you to control your JSP, JSTL or GSP page output based on the current Subject's state. This is quite useful for personalizing views based on the identity and authorization state of the current user viewing the web page.

Tag Library Configuration

The Tag Library Descriptor (TLD) file is bundled in shiro-web.jar in the META-INF/shiro.tld file. To use any of the tags, add the following line to the top of your JSP page (or wherever you define page directives):

<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>

We've used the shiro prefix to indicate the shiro tag library namespace, but you can assign whatever name you like.

Now we'll cover each tag and show how it might be used to render a page.

官网对于shiro标签说明 ,它支持jsp,jstl,gsp等前端技术,但是不支持themleaf。
但是在https://github.com/theborakompanioni/thymeleaf-extras-shiro中提供一个
thymeleaf-extras-shiro技术,相当于thymeleaf的扩展。

maven 配置如下:

    com.github.theborakompanioni
    thymeleaf-extras-shiro
    1.1.0


spring mvc 配置文件中配置如下:

 
   
          class="org.thymeleaf.templateresolver.ServletContextTemplateResolver">
       
       
       
       
   
   
          class="org.thymeleaf.spring4.SpringTemplateEngine">
       
       
           
               
           
       
   
   
       
       
   


页面则可以使用 shiro标签:

     
  • shiro:hasPermission ="SearchFile">
  •          
            文件管理
         


    官方说明:https://github.com/theborakompanioni/thymeleaf-extras-shiro

    你可能感兴趣的:(SSH)