zoukankan      html  css  js  c++  java
  • 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自定义标签


  • 相关阅读:
    yocto/bitbake 学习资源
    QEMU/KVM学习资源
    ubuntu 中创建和删除用户
    git 重命名本地和远程分支
    Ubuntu 上搭建 FTP 服务器
    gdb 常见用法
    git log 显示与特定文件相关的 commit 信息
    基于 qemu system mode 运行 arm 程序
    基于 qemu user mode 运行 aarch64 程序
    checking in(airport)
  • 原文地址:https://www.cnblogs.com/zhousiwei/p/10625861.html
Copyright © 2011-2022 走看看