s:iterator遍历

来源:互联网 发布:lte无线网络优化 编辑:程序博客网 时间:2024/05/01 09:36
<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
原创粉丝点击