读书人

Struts2采取velocity作为view后增加

发布时间: 2012-10-21 09:00:08 作者: rapoo

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

作为记号,怕搞忘:

?

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

?

在velocity.peroperties中增加选项:

resource.loader=strutsfile, strutsclass, filefile.resource.loader.path=/home/vm?其中,resource.loader表示定义了velocity资源装载的方式。struts2中默认为strutsfile和strutsclass,需要增加:file
并且还要增加查找地址:file.resource.loader.path,这个选项指定了.vm文件存放地址。
这样配置后,velocity模板引擎会按照定义的先后顺序查找.vm文件。

读书人网 >软件架构设计

热点推荐