velocity

代码如:
#set($i=0)
#foreach($product in $pageInfo.result)		 
     $!product.productBaseDto.productname
     $!distributorsFavourites.get($i).id      
#set($i=$i+1)
#end

#set($nums=[-2 .. 2])

#foreach($i in $nums)    
 
	$i

#end

输出:-2 -1 0 1 2
//map输出:

#foreach($key in $allElems.keySet()) 
   
 Key:$key ---> Value:$allElems.get($key)<br>

#end

 

//重载get方法
public BigDecimal getMinBuyerPrice( int scale) {
	//四舍五入
	return	MathUtil.round(minBuyerPrice, scale, BigDecimal.ROUND_HALF_UP);
}
public static BigDecimal round(BigDecimal value, int scale, int roundingMode) {
	if (scale < 0) {
		throw new IllegalArgumentException(
			"The scale must be a positive integer or zero");
	}
	if (value == null) {
		return new BigDecimal(0.00);
	}
	return value.setScale(scale, roundingMode);
}
//velocity页面:
$!product.productSaleSettingDto.getMinBuyerPrice(2)

 

$velocityCount循环中使用,默认从1开始
<li #if($velocityCount==1) class="current" #end></li>

 

eclipse编辑vm插件veloeclipsehttp://veloeclipse.googlecode.com/svn/trunk/update/    可以在windows--首选项改变javascript等显示的颜色。

veloeclipse安装

Help-->install new software-->Add 增加
Name:Veloeclipse
Value:http://veloeclipse.googlecode.com/svn/trunk/update/
然后选择Veloeclipse,再单击next
若无法列出该地址下的内容,只要在安装插件的界面中把 Group Items by Catagory 前打钩去掉就可以了!

 

 

 

 

你可能感兴趣的:(velocity)