标签:style blog http io color ar os 使用 java
http://blog.csdn.net/madding/article/details/6641020当在velocity中需要显示一个列表信息,我们会用foreach循环输出,
要求:
假如现在需要在页面中输出单数的内容背景为红,双数的内容为黑,构造方式如下:
BaseTestCase是Velocity源代码中的测试类
说明:
1.#foreach是velocity指令,
2.velcotiyCount上, velocity foreach定义的一个变量,该变量主要用来记录当前的循环次数
3.velocityHasNext, velocity foreach定义的一个变量 ,表明该循环当前是否到尾部了
velocity.properties:
实战记录
<?xml version="1.0" encoding="GBK"?> <PACKET type="REQUEST" version="1.0"> #set($base="PlyMain") #set($insured="Insured") #set($contactInfo="ContactInfo") <HEAD> <REQUEST_TYPE>$!{REQUEST_TYPE}</REQUEST_TYPE> <USER>$!{USER}</USER> <PASSWORD>$!{PASSWORD}</PASSWORD> </HEAD> <BODY> <VOUCHER_FLAG>$!{app.getComponent($contactInfo).get(0).getCVoucherFlag()}</VOUCHER_FLAG> <AA_INSURANCELIST> ## AA_INSURANCE信息 #foreach ($count in $AA_INSURANCECountList) <AA_INSURANCE> <NAME>$!{app.getComponent($insured).get($count).getCInsuredNme()}</NAME> <DD_PLYNO>$!{app.getComponent($base).get($count).getCDD_PLYNO()}</DD_PLYNO> </AA_INSURANCE> #end </AA_INSURANCELIST> </BODY> </PACKET>
标签:style blog http io color ar os 使用 java
原文地址:http://www.cnblogs.com/svennee/p/4078974.html