原 在spring boot项目中,如何整合freemarker与shiro标签使用
4956 | 0 | 0
一、导入依赖包
<!-- 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>
0
132****1346
3人已关注
领课教育 32105
9921
update 47195
4986
领课教育 18070
husheng 20978
请更新代码 41635
凯哥Java 2243
凯哥Java 2622
凯哥Java 2009