spring mvc +velocity
来源:互联网 发布:淘宝网页设计招聘 编辑:程序博客网 时间:2024/06/06 04:55
项目中引入jar包:
applicationcontext.xml 配置
<!-- 配置velocity引擎 --> <bean id="velocityConfigurer" class="org.springframework.web.servlet.view.velocity.VelocityConfigurer"> <property name="resourceLoaderPath" value="/WEB-INF/templates/" /><!-- 模板存放的路径 --> <property name="configLocation" value="classpath:velocity.properties" /> </bean> <!-- 配置视图的显示 --> <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>tool.xml和velocity.properties 两个文件,在jar包中都可以找到的
velocity.jar velocity.properties -->> org.apache.velocity.runtime.defaults.velocity.properties
velocity-tool.jar tools.xml -->> org\apache\velocity\tools\generic\tools.xml 记得改下标签。
velocity.properties要改一下
velocimacro.library = /macros.vminput.encoding=UTF-8output.encoding=UTF-8
macros.vm这个随你自己想不想要,反正默认也是会加载好多spring的宏的。编码是一定要设置的。
明明已经都配置好了,自己都觉得没问题了,action都进了,最后跳到模板引擎去加载模板的时候,告诉你这个模板找不到!!
经过仔细排查,是velocity.properties多了句配置,自己需要注释一下。
#file.resource.loader.path = .将这句配置注释,这是说,路径为properties文件路径,但如果你的properties跟你的templates不在一个目录,这时候就会出问题了。我调进去看过,它默认就是templates目录,上面宏的地址,也是相对于templates的目录。
0 0
- Spring MVC 整合Velocity
- Spring MVC 集成 Velocity
- spring mvc 整合 velocity
- spring mvc整合velocity
- Spring MVC整合Velocity
- Spring MVC 集成 Velocity
- Spring MVC配置Velocity
- spring mvc velocity使用
- Spring MVC整合Velocity
- spring mvc +velocity
- Spring MVC整合Velocity
- spring mvc+velocity+maven
- Spring MVC 集成Velocity
- Spring MVC 与 Velocity 整合
- spring mvc+velocity整合开发
- spring mvc 集成velocity模板
- 2、Spring MVC整合Velocity
- spring mvc 与velocity配置
- 最全面的常用正则表达式大全
- Idea15卸载自己装的插件
- android zxing二维码扫描界面参数修改
- FreeMarker整合Spring 3
- linux快速切换用户
- spring mvc +velocity
- html 链接到同一个页面的不同位置
- mysql:用户管理
- 我眼中的Linux设备树(五 根节点)
- 使用 Spring Boot 快速构建 Spring 框架应用
- 我眼中的Linux设备树(六 memory&chosen节点)
- Static 的作用
- 统计学上的P值的含义通俗
- 内存泄漏