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. 填写项目配 ...
随机推荐
- retry policy is RetryUpToMaximumCountWithFixedSleep(maxRetries=10, sleepTime=1 SECONDS)
[root@qa bin]# hadoop fs -ls / Warning: $HADOOP_HOME is deprecated. 14/07/29 13:25:35 INFO ipc.Clien ...
- 对ESB概念的理解(转)
http://www.ibm.com/developerworks/cn/webservices/0811_magy_esb/ 什么是 ESB?ESB 严格来说不是某一个产品,而是一种框架,设计模式. ...
- Java设计模式菜鸟系列(十四)代理模式建模与实现
转载请注明出处:http://blog.csdn.net/lhy_ycu/article/details/39856435 代理模式(Proxy):代理模式事实上就是多一个代理类出来,替原对象进行一些 ...
- docker 现实---联网多台物理主机,容器桥到物理网络(三)
docker 默认桥接卡docker0 只有当这个单元中的所有容器桥接卡.例如,在主机虚拟网络适配器容器看通常称为veth*** 和docker只要把这些卡桥接在一起,例如下面的附图: waterm ...
- S2SH新手框架结构的准备工作只需要导入这些文件
实习北京最近一直在某公司.时间很冲突,总想着有事找东西坐,思想,做事先成套我吧 一套完整的东西想好主题,术去实现了,在学校尽管说是学了J2EE,可是确实没学到东西,Struts2+Hibernate不 ...
- php方法综述除去换行符(PHP_EOL使用变量)
一个小包裹,事实上,不同的平台具有不同的实现.为什么要这样.它可以是一个世界是多样的. 最初unix与世界把它包/n取代,但windows为了体现自己的不同.要使用/r/n,更有意思的是,mac随着/ ...
- Android L中间RecyclerView 、CardView 、Palette使用
RecyclerView CardView Palette <Material Design>提到,Android L版本号中新增了RecyclerView.CardView .Palet ...
- SDUT OJ 2463 学校password你必须学会科学计划
#include<iostream> #include<string.h> #include<stdio.h> #define N 10010 #define M ...
- Data URI(转)
Data URL 早在 1995 年就被提出,那个时候有很多个版本的 Data URL Schema 定义陆续出现在 VRML 之中,随后不久,其中的一个版本被提上了议案——将它做个一个嵌入式的资源放 ...
- 于ubuntu配置hadoop当问题
1. 构造ssh登录 我们并不需要改变/etc/ssh/sshd_config 2. 新hadoop用户,home下列不hadoop夹 创建使用下面的命令 useradd -m hadoop 3. n ...