zoukankan      html  css  js  c++  java
  • springboot使用freemarker shiro标签

    <!-- freemarker + shiro(标签) begin -->
            <dependency>
                <groupId>net.mingsoft</groupId>
                <artifactId>shiro-freemarker-tags</artifactId>
                <version>1.0.0</version>
            </dependency>
            <!-- freemarker + shiro(标签) begin -->
    import com.jagregory.shiro.freemarker.ShiroTags;
    import freemarker.template.TemplateModelException;
    import org.slf4j.Logger;
    import org.slf4j.LoggerFactory;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.stereotype.Component;
    import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer;
    
    import javax.annotation.PostConstruct;
    
    /**
     * @Author: SimonHu
     * @Date: 2020/6/8 17:02
     * @Description:
     */
    @Component
    public class ShiroTagsFreeMarkerCfg {
        private static final Logger log = LoggerFactory.getLogger(ShiroTagsFreeMarkerCfg.class);
        @Autowired
        private FreeMarkerConfigurer freeMarkerConfigurer;
        
        @PostConstruct
        public void setSharedVariable() throws TemplateModelException {
            log.info("设置freeMarker 的shiro 标签");
            freeMarkerConfigurer.getConfiguration().setSharedVariable("shiro", new ShiroTags());
        }
    }
    <!-- html 静态页面 -->
    <
    div class="layui-side layui-side-bg layui-larry-side" id="larry-side"> <div class="layui-side-scroll" id="larry-nav-side" lay-filter="side"> <div class="user-photo"> <a class="img" title="我的头像"><img src="http://api.zihexin.net/appimages/ad/20190702/17348339484_1080.png"></a> <p>你好!<span class="userName"><@shiro.principal property='username'/></span>, 欢迎登录</p> </div> <!-- 左侧菜单 --> <ul class="layui-nav layui-nav-tree"> <menu-item :item="item" v-for="item in menuList"></menu-item> </ul> </div> </div>

  • 相关阅读:
    mariadb配置双主多从
    mq系列rabbitmq-02集群+高可用配置
    mq系列rabbitmq-01简介,安装,api操作
    持续集成框架jenkins介绍02-持久集成git仓库+maven项目
    git仓库相关知识03-搭建远程仓库服务器
    RecyclerView瀑布流优化方案探讨
    Android实际开发bug大总结
    Android打造万能自定义阴影控件
    PagerAdapter深度解析和实践优化
    Java博客大汇总
  • 原文地址:https://www.cnblogs.com/SimonHu1993/p/13066857.html
Copyright © 2011-2022 走看看