• Velocity模版自定义标签


    	<!-- Velocity视图解析器 默认视图 -->
    	<bean id="velocityViewResolver"
    		class="org.springframework.web.servlet.view.velocity.VelocityViewResolver">
    		<property name="contentType" value="text/html;charset=UTF-8" />
    		<property name="viewNames" value="*.html" />
    		<property name="suffix" value="" />
    		<property name="dateToolAttribute" value="date" />
    		<property name="numberToolAttribute" value="number" />
    		<property name="toolboxConfigLocation" value="/WEB-INF/velocity-toolbox.xml" />
    		<property name="requestContextAttribute" value="rc" />
    		<property name="order" value="0" />
    	</bean>

    加上  <property name="toolboxConfigLocation" value="/WEB-INF/velocity-toolbox.xml" />   路径随便自己定义


    现在创建velocity-toolbox.xml文件

    <?xml version="1.0" encoding="UTF-8" ?>
    <toolbox>
    	<!-- velocity 自定义标签 -->
    	<tool>
    	    <key>shiro</key>
    	    <scope>application</scope>
    	    <class>com.wstro.shiro.VelocityShiro</class>
    	</tool>
    </toolbox>

    key  随便自己定义  就是前台模版使用的

    scope一般写application全局都能使用就可以了

    class  使用到的类

    前台直接调用


    #if($shiro.hasPermission("backuprecord:save"))
    			你有backuprecord:save  权限
    			#end


    类没有什么。和普通的java类一样;。方法不能是静态的,然后调用它的方法,可以传参


    还有:freemarker自定义标签


  • 相关阅读:
    Contest (树状数组求逆序对)
    树状数组
    unity3D 笔记 (NENE QUEST 制作中用到的函数)
    Ubuntu 安装gnome桌面及vnc远程连接
    Pillow图像处理
    室内场景数据集
    PyTorch踩坑笔记
    进一步了解pip
    一些概念
    损失函数及评价指标
  • 原文地址:https://www.cnblogs.com/zhousiwei/p/10625859.html
Copyright © 2020-2023  润新知