也许你需要实现自己的迭代器 - 它只是存储BigDecimals的列表的开始和结束,并返回当前之一。通过这种方式,你可以有一个数字无限大小的列表(我认为是你想要的,因为你正在使用BigDecimals的。否则,只使用int或长):
#set ($countIterator = ${item.qtyIterator})
#foreach($i in $countIterator)
${i}
....use $i as a string...
#end
和
public class QuantityIterator implement Iterator<BigDecimal> {
QuantityIterator(BigDecimal start, BigDecimal end) { this.start = start;this.end=end;}
//..implement the iterator methods like hasNext() etc
public hasNext() {return this.current.compareTo(this.end) < 0;} //current <= end
public BigDecimal next() {
if (!hasNext()) {
throw new NoSuchElementException();
}
this.current = this.current.add(BigDecimal.ONE);
return this.current;
}
public void remove(){throw new UnsupportedException();}
}
是否将'qty'改为int,在bean中有效? – 2009-10-20 04:59:54