velocity

本文深入探讨了代码片段中的循环结构、数学运算、Velocity页面模板的使用及JavaScript编辑器插件的配置,包括代码重载方法、输出格式化、页面元素的循环展示与样式调整。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

代码如:
#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 前打钩去掉就可以了!

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值