velocity是什么

velocity是什么
其他人气:554 ℃时间:2020-10-01 14:04:03
优质解答
一种J2EE的前端模版技术.
和JSP,Freemarker差不多,都是用来展示网页内容的.
和JSP不同的是velocity只能显示Action中的数据,不能处理数据.不能写java代码,但是可以使用Velocity标记.
Velocity的页面(模版)可是是任何类型(text/html)的文件.
比如Action中有如下两个属性.
class XxxAction{
private String title;
private String name;
public String execute(){
this.name = "Tom";
this.title="HelloWord";
return "velocity";
}
//getter & setter 必须要提供getter
}
struts.xml
a.html
velocity会将标记部分替换掉.
a.html
${title}
hello ${name}
最终将会返回页面如下:
HelloWord
hello Tom
注:这个例子需要在struts2下,并且加入velocity jar包.
我来回答
类似推荐
请使用1024x768 IE6.0或更高版本浏览器浏览本站点,以保证最佳阅读效果。本页提供作业小助手,一起搜作业以及作业好帮手最新版!
版权所有 CopyRight © 2012-2024 作业小助手 All Rights Reserved. 手机版