<!-- 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類一樣;。方法不能是靜態的,然后調用它的方法,可以傳參