java seasar2 jsp EL 式 Mapのデータ表示 

seaser2使用している場合です。
//フォーム
public class TestForm {

 public Map<String, String> testMap = null;

}

//アクションでのFormの定義

 @ActionForm
 @Resource
 public TestForm testForm = null;
//アクションでMap詰める
Map<String, String> testMap = new LinkedHashMap<String, String>();
for(int i = 0; i <= 23; i++) {
 testMap.put(String.valueOf(i), String.valueOf(i*10));
}
testForm.testMap = testMap; 
//jsp
<c:forEach var=”testMap”  items=”${testForm.testMap}”>
 <bean:define id=”key”  name=”testMap” property=”key” ></bean:define>
 <bean:define id=”value”  name=”testMap” property=”value” ></bean:define>
 <c:out value=”${f:h(key)}”></c:out>
 <c:out value=”${f:h(value)}”></c:out>
</c:forEach>

コメントを残す

メールアドレスが公開されることはありません。