thymeleaf模板引擎shiro集成框架
shiro权限框架。前端验证jsp设计。间tag它只能用于jsp系列模板引擎。
使用最近项目thymeleaf作为前端模板引擎,采用HTML档,未出台shiro的tag lib,假设你想利用这段时间shiro如果,可以引入 thymeleaf-extras-shiro.jar这个拓展包来曲线实现shiro的前端验证。
在pom.xml中增加例如以下依赖:
<dependency>
<groupId>com.github.theborakompanioni</groupId>
<artifactId>thymeleaf-extras-shiro</artifactId>
<version>1.0.2</version>
</dependency>
关于版本号,能够在maven仓库中查询:http://mvnrepository.com/artifact/com.github.theborakompanioni/thymeleaf-extras-shiro/1.0.2
thymeleaf-extras-shiro.jar在git hub的地址:https://github.com/theborakompanioni/thymeleaf-extras-shiro。上面有详细的使用说明。
引入jar包后,我们要简单设置一下thymeleaf的引擎:
<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>
或者假设使用的是Java代码配置的话:
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;
}
然后就能够在页面中使用thymeleaf化的shiro标签来进行前端验证了。
shiro本身的标签有限,没有hasAnyPermission标签,我在之前的一篇文章中《自己定义shiro标签》有写过jsp标签的版本号。事实上,在这里假设使用的是thymeleaf,也能够自己定义拓展一下shiro的hasAnyPermission。
将下载下来的thymeleaf-extras-shiro.jar打开,会有一个shiro-dialect.xml的文件,这里定义了thymeleaf的shiro属性,我们也能够依据这里面的样例进行简单拓展。
这里事实上是在拓展thymeleaf,官方文档中有具体的说明和简单的例子,对比文档,学习会更快。
版权声明:本文博主原创文章,博客,未经同意不得转载。
thymeleaf模板引擎shiro集成框架的更多相关文章
- 九、SpringBoot集成Thymeleaf模板引擎
Thymeleaf咋读!??? 呵呵,是不是一脸懵逼...哥用我的大学四级英文知识告诉你吧:[θaimlif]. 啥玩意?不会音标?...那你就这样叫它吧:“赛母李府”,大部分中国人是听不出破绽的.. ...
- SpringBoot--- Shiro(拦截,认证)、Thymeleaf(模板引擎)
SpringBoot--- Shiro(拦截,认证).Thymeleaf(模板引擎) 环境 IDEA :2020.1 SpringBoot: 2.3.3 Java : 8 版本依赖: shiro- ...
- 【Springboot】Springboot整合Thymeleaf模板引擎
Thymeleaf Thymeleaf是跟Velocity.FreeMarker类似的模板引擎,它可以完全替代JSP,相较与其他的模板引擎,它主要有以下几个特点: 1. Thymeleaf在有网络和无 ...
- SpringBoot入门篇--使用Thymeleaf模板引擎进行页面的渲染
在做WEB开发的时候,我们不可避免的就是在前端页面之间进行跳转,中间进行数据的查询等等操作.我们在使用SpringBoot之前包括我在内其实大部分都是用的是JSP页面,可以说使用的已经很熟悉.但是我们 ...
- Spring Boot2(五):使用Spring Boot结合Thymeleaf模板引擎使用总结
一.Thymeleaf概述 一般来说,常用的模板引擎有JSP.Velocity.Freemarker.Thymeleaf . SpringBoot推荐的 Thymeleaf – 语法更简单,功能更强大 ...
- (二)SpringBoot基础篇- 静态资源的访问及Thymeleaf模板引擎的使用
一.描述 在应用系统开发的过程中,不可避免的需要使用静态资源(浏览器看的懂,他可以有变量,例:HTML页面,css样式文件,文本,属性文件,图片等): 并且SpringBoot内置了Thymeleaf ...
- 三、thymeleaf模板引擎构建前台html, 后台使用 ModelAndView 和 Model 模型
项目源码:https://github.com/y369q369/springBoot.git -> thymeleaf 私聊QQ: 1486866853 1.pom.xml中 ...
- SpringBoot使用thymeleaf模板引擎
(1).添加pom依赖 <dependency> <groupId>org.springframework.boot</groupId> <artifactI ...
- Spring Boot 2.0 整合Thymeleaf 模板引擎
本节将和大家一起实战Spring Boot 2.0 和thymeleaf 模板引擎 1. 创建项目 2. 使用Spring Initlizr 快速创建Spring Boot 应用程序 3. 填写项目配 ...
随机推荐
- html 格式的email 编辑
本篇文章只讲如何编辑html格式的email 模板,并不讲述如何用程序发送email. 1.做email的重要思想:“复古” 抛弃现代化的div+css技术,回到html4.0+table的时代.少用 ...
- Directx11学习笔记【六】 基本的数学知识----矩阵篇
参考dx11龙书 Chapter2 matrix algebra(矩阵代数) 关于矩阵的一些基本概念定理(例如矩阵加减乘法,逆矩阵,伴随矩阵,转置矩阵等)可以参考维基百科 https://zh.wik ...
- YT新人之巅峰大决战04
Problem Description Eddy's interest is very extensive, recently he is interested in prime number. Ed ...
- Intel® Ethernet Connection I217-V 网卡驱动(win10 ,2012)
https://downloadcenter.intel.com/zh-cn/download/25016/-Windows-10 上面是win10 的驱动 win8.1 https://downl ...
- 文件搜索神器everything 你不知道的技巧总结
everything这个软件用了很久,总结了一些大家可能没注意到的技巧,分享给大家 1.指定文件目录搜索示例: TDDOWNLOAD\ abc 在所有TDDOWNLOAD文件夹下搜索包含 ...
- [原创].NET 业务框架开发实战之八 业务层Mapping的选择策略
原文:[原创].NET 业务框架开发实战之八 业务层Mapping的选择策略 .NET 业务框架开发实战之八 业务层Mapping的选择策略 前言:在上一篇文章中提到了mapping,感觉很像在重新实 ...
- RH133读书 笔记(5) - Lab 5 User and Group Administration
Lab 5 User and Group Administration Goal: To build skills for user and group administration. Estimat ...
- JavaScript变量作用域和内存问题(二)
执行环境是js中特别重要的概念,是指变量或者函数可以访问其他数据,定义自己的行为.每个执行环境都有一个与之相对应的变量对象,执行环境中定义的所有变量和函数都保存在这个变量中,我们看不到这个变量,但是后 ...
- Servlet实例解说
打开昨天上午,负责人突然问我,client控制信息,如何让在后台?我想回答:假设总体提交form,在C#使用代码request获取表单的内容.假设局部提交,在用JS和Ajax交互,通过Ajax的ope ...
- Unity GUI选择与评价
因为Unity内建的GUI不管是不是从开发效率或效率强制,因此,许多派生GUI插入,什么插件的选择,是一个非常值它被认为是. 既然是评价,就会有非常多的主观意识,这不一定成为选择的根据. 再比方.我已 ...