您现在的位置是:首页 > 文章详情

在spring boot项目中,如何整合freemarker与shiro标签使用

日期:2018-11-29点击:1107

一、导入依赖包

<!-- freemarker + shiro(标签)-->
<dependency>
    <groupId>net.mingsoft</groupId>
    <artifactId>shiro-freemarker-tags</artifactId>
    <version>0.1</version>
</dependency>

二、在项目中添加配置

package com.web.common.config;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.jagregory.shiro.freemarker.ShiroTags;

import freemarker.template.Configuration;

@Component
public class PlatformFreeMarkerConfigurer implements InitializingBean {

	@Autowired
	private Configuration configuration;

	@Override
	public void afterPropertiesSet() throws Exception {
		// 加上这句后,可以在页面上使用shiro标签
		configuration.setSharedVariable("shiro", new ShiroTags());
	}
}

三、

<@shiro.hasPermission name="admin:add">
    <a href="${base}/admin/user/role/add">添加角色</a>
</@shiro.hasPermission>

<@shiro.hasPermission name="admin:update">
    <a href="${base}/admin/user/role/edit?id=${bean.id}">修改</a>
    <a href="${base}/admin/user/role/delete?id=${bean.id}">删除</a>
</@shiro.hasPermission>


原文链接:https://blog.roncoo.com/article/128254
关注公众号

低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。

持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。

转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。

文章评论

共有0条评论来说两句吧...

文章二维码

扫描即可查看该文章

点击排行

推荐阅读

最新文章