Shiro permissions framework, front-end validation is designed for JSP, where the tag can only be used for the JSP series template engine. The recent project uses Thymeleaf as the front-end template engine, using HTML files, unable to introduce Shiro's tag lib, if you want to use Shiro, you can introduce Thymeleaf-extras-shiro.jar This expansion package curve realizes the Shiro front-end verification.
Add the following dependencies to the Pom.xml:
<dependency>
<groupId>com.github.theborakompanioni</groupId>
<artifactId> thymeleaf-extras-shiro</artifactid>
<version>1.0.2</version>
</dependency>
For versions, you can query in the MAVEN repository: http://mvnrepository.com/artifact/com.github.theborakompanioni/thymeleaf-extras-shiro/1.0.2
Thymeleaf-extras-shiro.jar at the address of the Git hub: Https://github.com/theborakompanioni/thymeleaf-extras-shiro, which has specific instructions for use.
After introducing the jar package, we will simply set up the Thymeleaf engine:
<bean id= "Templateengine" class= "Org.thymeleaf.spring3.SpringTemplateEngine" >
<property name= " Templateresolver "ref=" Templateresolver "/>
<property name=" additionaldialects ">
<set>
<bean class= "At.pollux.thymeleaf.shiro.dialect.ShiroDialect"/>
</set>
</property >
</bean>
Or, if you are using Java code configuration:
Public Springtemplateengine Templateengine () {
Springtemplateengine templateengine = new Springtemplateengine ();
Templateengine.settemplateresolver (Templateresolver ());
set<idialect> additionaldialects = new hashset<idialect> ();
Additionaldialects.add (New Shirodialect ());
Templateengine.setadditionaldialects (additionaldialects);
return templateengine;
}
You can then use the Thymeleaf Shiro tag in the page to verify the front end.
Shiro the label itself is limited, there is no hasanypermission tag, I wrote in a previous article, "Custom Shiro label" has written the JSP tag version, in fact, if you use the thymeleaf here, You can also customize the extension of Shiro Hasanypermission.
Will download the Thymeleaf-extras-shiro.jar open, there will be a shiro-dialect.xml file, which defines the Thymeleaf Shiro properties, we can also be based on the example of the simple extension.
This is in fact the expansion of the Thymeleaf, the official documents have detailed instructions and simple examples, compared to the document, learning will be faster.