s:iterator遍历

<pre name="code" class="html"><SELECT id="induVer" name="condition.induVer">
					<option value="">-请选择-</option>
					<s:iterator value="#request.induCache.get(0)">
						<option value="${INDU_VER}" <s:if test="condition.induVer==INDU_VER">selected</s:if>>
							<s:iterator value="#request.dictEntryMap.DC_INDU_VER" var="mp">
								<s:if test="#mp.key==INDU_VER">
									<s:property value="#mp.value" />
								</s:if>
							</s:iterator>
						</option>
					</s:iterator>
				</SELECT>
				<SELECT id="induCode" name="condition.induCode" value="${condition.induCode}">
					<option value="">-请选择-</option>
					<s:iterator value="#request.induCache.get(1)">
						<option value="${INDU_CODE}" <s:if test="condition.induCode==INDU_CODE">selected</s:if>>
							<s:iterator value="#request.dictEntryMap.DC_INDU_CODE" var="mp">
								<s:if test="#mp.key==INDU_CODE">
									<s:property value="#mp.value" />
								</s:if>
							</s:iterator>
						</option>
					</s:iterator>
				</SELECT>


 

<pre name="code" class="html"><c:if test="${not empty msgList}">
					<table width="100%" class="table">
						<tr>
							<th>
								企业中文名
							</th>
							<th>
								企业贷款卡号
							</th>
							<th>
								行业版本
							</th>
							<th>
								行业范围
							</th>
							<th>
								错误信息
							</th>
						</tr>
						<s:iterator value="#request.msgList" status="st">
							<tr>
								<s:iterator value="#request.msgList.get(#st.index)" id="obj">
									<td>
										<!-- ${obj} <span style="font-family: Arial, Helvetica, sans-serif;">--></span>
										<s:property />
									</td>
								</s:iterator>
							</tr>
						</s:iterator>
					</table>
				</c:if>
</pre>List<List>:<pre name="code" class="html"><table width="100%" class="table"><tr><th>企业中文名</th><th>企业贷款卡号</th><th>行业版本</th><th>行业范围</th><th>错误信息</th></tr><s:iterator value="{{'1','2','3','2','3'},{'1','2','3','2','3'}}"id="lst"><tr><s:iterator value="lst" id="obj" status="indx"><td>${obj}</td></s:iterator></tr></s:iterator></table><pre>

 
</pre><pre name="code" class="java">
public static void main(String[] args) {


  Map<String, String> map = new HashMap<String, String>();
  map.put("1", "value1");
  map.put("2", "value2");
  map.put("3", "value3");
  
  //第一种:普遍使用,二次取值
  System.out.println("通过Map.keySet遍历key和value:");
  for (String key : map.keySet()) {
   System.out.println("key= "+ key + " and value= " + map.get(key));
  }
  
  //第二种
  System.out.println("通过Map.entrySet使用iterator遍历key和value:");
  Iterator<Map.Entry<String, String>> it = map.entrySet().iterator();
  while (it.hasNext()) {
   Map.Entry<String, String> entry = it.next();
   System.out.println("key= " + entry.getKey() + " and value= " + entry.getValue());
  }
  
  //第三种:推荐,尤其是容量大时
  System.out.println("通过Map.entrySet遍历key和value");
  for (Map.Entry<String, String> entry : map.entrySet()) {
   System.out.println("key= " + entry.getKey() + " and value= " + entry.getValue());
  }

  //第四种
  System.out.println("通过Map.values()遍历所有的value,但不能遍历key");
  for (String v : map.values()) {
   System.out.println("value= " + v);
  }
 }

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值