計算のために同じ順序で出力する必要がある、順番に名前が付けられたフィールド(field1、field2など)を持つフォームがあります。JSTLは、デフォルトではアルファベット順にソートされていないようです。そうする方法はありますか?
コードは次のとおりです。
<c:if test="${param.submitted}">
<c:set var="hits" value="1" />
<c:set var="damage" value="0" />
<table border="1">
<tr>
<th>Attack</th>
<th>Damage (Orig)</th>
<th>Damage (Scaled)</th>
<th>Total</th>
</tr>
<!-- Loop through form fields -->
<c:forEach var="information" items="${paramValues}" varStatus="field">
<!-- Loop through fields' values -->
<tr>
<c:forEach var="currentField" items="${information.value}">
<c:if test="${!empty currentField}">
<c:if test="${fn:contains(currentField, '|')}">
<c:set var="currentAttack" value="${fn:substringAfter(currentField, '|')}" />
<td><c:out value="${hits}" />: <c:out value="${fn:substringBefore(currentField, '|')}" /></td>
<td><c:out value="${fn:substringAfter(currentField, '|')}" /></td>
<td>
<c:choose>
<c:when test="${hits < 3}">
<c:out value="${currentAttack}" />
<c:set var="damage" value="${damage + currentAttack}" />
</c:when>
<c:when test="${hits == 3}">
<c:out value="${currentAttack * 0.8}" />
<c:set var="damage" value="${damage + (currentAttack * 0.8)}" />
</c:when>
<c:when test="${hits == 4}">
<c:out value="${currentAttack * 0.7}" />
<c:set var="damage" value="${damage + (currentAttack * 0.7)}" />
</c:when>
<c:when test="${hits == 5}">
<c:out value="${currentAttack * 0.6}" />
<c:set var="damage" value="${damage + (currentAttack * 0.6)}" />
</c:when>
<c:when test="${hits == 6}">
<c:out value="${currentAttack * 0.5}" />
<c:set var="damage" value="${damage + (currentAttack * 0.5)}" />
</c:when>
<c:when test="${hits == 7}">
<c:out value="${currentAttack * 0.4}" />
<c:set var="damage" value="${damage + (currentAttack * 0.4)}" />
</c:when>
<c:when test="${hits == 8}">
<c:out value="${currentAttack * 0.3}" />
<c:set var="damage" value="${damage + (currentAttack * 0.3)}" />
</c:when>
<c:when test="${hits == 9}">
<c:out value="${currentAttack * 0.2}" />
<c:set var="damage" value="${damage + (currentAttack * 0.2)}" />
</c:when>
<c:otherwise>
<c:out value="${currentAttack * 0.1}" />
<c:set var="damage" value="${damage + (currentAttack * 0.1)}" />
</c:otherwise>
</c:choose>
</td>
<td><c:out value="${damage}" /></td>
<c:set var="hits" value="${hits + 1}" />
</c:if>
</c:if>
</c:forEach>
</tr>
</c:forEach>
</table>
</c:if>
<form action="foo.jsp" method="post">
<input type="hidden" name="submitted" value="true" />
<c:forEach var="rows" begin="1" end="5" varStatus="stat">
<p> ${stat.count}:
<select name="move${stat.count}">
<option value="">-Select-</option>
<c:forEach var="row" items="${result.rows}">
<option value="${row.attack}|${row.damage}">${row.attack}</option>
</c:forEach>
</select></p>
</c:forEach>
<input type="submit" name="submit" value="Go" />
</form>