spring4.x怎么集成velocity问题

J2EE 码拜 9年前 (2015-09-09) 1829次浏览

 

请问一下spring4.x怎么集成velocity?

spring3.x中org.springframework.web.servlet.view.velocity.VelocityConfigurer有属性可以设置resourceLoaderPath和configLocation。但是spring4.x找不到这两个属性。我查了spring官方的文档,但是文档上依旧是原来的配置方法,拷贝过来用不了,提示没有setter方法。

#1

50分

楼主去这看看吧

http://www.oschina.net/question/1245614_148092

希望能帮到你

#2

50分

1:定义velocity视图

2:配置velocity引擎

<bean id=”velocityConfigurer”

class=”org.springframework.web.servlet.view.velocity.VelocityConfigurer”>

<property name=”resourceLoaderPath” value=”/WEB-INF/templates/” />

</bean>

3:解析velocity视图

<bean id=”ViewResolver” class=”org.springframework.web.servlet.view.velocity.VelocityLayoutViewResolver”>

<property name=”prefix” value=”/” /><!– 视图文件的前缀,即存放的路径 –>

<property name=”suffix” value=”.vm” /><!– 视图文件的后缀名 –>

<property name=”toolboxConfigLocation” value=”/WEB-INF/tools.xml” /><!–toolbox配置文件路径–>

<property name=”dateToolAttribute” value=”date” /><!–日期函数名称–>

<property name=”numberToolAttribute” value=”number” /><!–数字函数名称–>

<property name=”contentType” value=”text/html;charset=UTF-8″ />

<property name=”exposeSpringMacroHelpers” value=”true” /><!–是否使用spring对宏定义的支持–>

<property name=”exposeRequestAttributes” value=”true” /><!–是否开放request属性–>

<property name=”requestContextAttribute” value=”rc”/><!–request属性引用名称–>

<property name=”layoutUrl” value=”layout/default.vm”/><!–指定layout文件–>

</bean>

4:暴露请求和会话属性

#3
真正的原因是因为maven少加入了spring-context-support模块

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明spring4.x怎么集成velocity问题
喜欢 (0)
[1034331897@qq.com]
分享 (0)