我有一個Java Bean的集合,我想使用迭代器標記在JSP中進行迭代。Struts 2迭代器標記
列表按此標籤排序的默認順序是什麼? 因爲它不按列表中添加bean的順序進行迭代。
這是Struts Action類代碼:
public String getUsersTraceJSP() {
try {
Map session = ActionContext.getContext().getSession();
Properties properties = new Properties();
InitialContext ic = new InitialContext(properties);
PartnerSessionBeanRemote bIRemote = (PartnerSessionBeanRemote) ic.lookup(PartnerSessionBeanRemote.class.getName());
UserLoginTraceForm ultf = bIRemote.getUserLoginTrace(Long.parseLong(userId));
for (UserLoginTraceForm uu : ultf.getUltList()) {
System.out.println("ULT ID | " + uu.getUltId());
}
session.put("ULTF", ultf);
} catch (Exception e) {
e.printStackTrace();
Logger.printError("ERROR", "AppFilesAction.getUsersTraceJSP() ", e);
}
return "success";
}
System.out.println("ULT ID | " + uu.getUltId())
給出了這樣的輸出:
INFO: ULT ID | 91
INFO: ULT ID | 9
INFO: ULT ID | 86
INFO: ULT ID | 84
INFO: ULT ID | 83
INFO: ULT ID | 82
INFO: ULT ID | 81
INFO: ULT ID | 8
INFO: ULT ID | 74
INFO: ULT ID | 73
INFO: ULT ID | 72
INFO: ULT ID | 71
INFO: ULT ID | 70
INFO: ULT ID | 7
INFO: ULT ID | 69
INFO: ULT ID | 68
INFO: ULT ID | 67
INFO: ULT ID | 66
INFO: ULT ID | 65
INFO: ULT ID | 64
INFO: ULT ID | 63
INFO: ULT ID | 62
INFO: ULT ID | 61
INFO: ULT ID | 6
INFO: ULT ID | 5
INFO: ULT ID | 49
INFO: ULT ID | 48
INFO: ULT ID | 47
INFO: ULT ID | 46
INFO: ULT ID | 45
INFO: ULT ID | 44
INFO: ULT ID | 43
INFO: ULT ID | 42
INFO: ULT ID | 41
INFO: ULT ID | 40
INFO: ULT ID | 4
INFO: ULT ID | 39
INFO: ULT ID | 38
INFO: ULT ID | 37
INFO: ULT ID | 36
INFO: ULT ID | 35
INFO: ULT ID | 34
INFO: ULT ID | 33
INFO: ULT ID | 32
INFO: ULT ID | 31
INFO: ULT ID | 30
而JSP是:
和輸出是這樣的:
<div class="row" style="height:92.5%;padding-left: 1%;padding-right: 1%;overflow: auto">
<div id="tableDiv" >
<table id="formList" class="display" cellspacing="0" width="100%">
<thead style="background-color: #BDC6E7">
<tr>
<th>ultId>
<th>Login Time</th>
<th>IP Address</th>
</tr>
</thead>
<tbody>
<s:iterator value="#session.ULTF.ultList">
<tr>
<td><s:property value="ultId"/></td>
<td><s:property value="loginTime"/></td>
<td><s:property value="ipAddress"/></td>
</tr>
</s:iterator>
</tbody>
</table>
</div>
</div>
「默認訂單」就是列表中迭代的任何順序。 – 2014-09-03 13:11:16
現在的問題是,println中顯示的訂單是不同的,並且在視圖中訂單的遞增順序爲ULT_ID – 2014-09-05 06:04:23
這就是* A圖片勝過千言萬語*。 :)你有一些數據網格。 – 2014-09-05 07:39:53