`
NetBus
  • 浏览: 143506 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

Struts2采用velocity作为view后,增加新的vm模板查找路径

阅读更多

作为记号,怕搞忘:

 

struts2的velocity引擎一般会以web根路径作为vm默认查找路径。如:#parse("/xx.vm"),则会到实际运行的web根目录下查找该文件。如果想增加外面的vm模板引用,则必须要更改velocity配置文件。

 

在velocity.peroperties中增加选项:

  • resource.loader=strutsfile, strutsclass, file
  • file.resource.loader.path=/home/vm 
其中,resource.loader表示定义了velocity资源装载的方式。struts2中默认为strutsfile和strutsclass,需要增加:file

并且还要增加查找地址:file.resource.loader.path,这个选项指定了.vm文件存放地址。

这样配置后,velocity模板引擎会按照定义的先后顺序查找.vm文件。
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics