如何使用 struts 标签库遍历 jsp 中的 Map<String, List<MyObject>>?
How to iterate over Map<String, List<MyObject>> in the jsp using struts tag library?
在后端我有一个地图:
SortedMap<String, List<MyObject>> myMap = new TreeMap<>()
MyObject
有 private String name
字段,公共 getter 和 setter
在 jsp 我有:
<nested:iterate property="myMap" id="map">
<bean:write name="map" property="key"/>
<nested:iterate property="listElement" id="value">
<bean:write name="value" property="name"/>
</nested:iterate>
</nested:iterate>
但我看到错误:
Caused by: javax.servlet.jsp.JspException: No getter method for property: "otherBean.MyMap(API).listElement" of bean: "MyBeanForm"
我该如何解决?
有效
<nested:iterate property="myMap" id="entry">
<bean:write name="entry" property="key"/>
<nested:iterate property="value" name="entry" id="obj">
<bean:write name="obj" property="name"/>
</nested:iterate>
</nested:iterate>
在后端我有一个地图:
SortedMap<String, List<MyObject>> myMap = new TreeMap<>()
MyObject
有 private String name
字段,公共 getter 和 setter
在 jsp 我有:
<nested:iterate property="myMap" id="map">
<bean:write name="map" property="key"/>
<nested:iterate property="listElement" id="value">
<bean:write name="value" property="name"/>
</nested:iterate>
</nested:iterate>
但我看到错误:
Caused by: javax.servlet.jsp.JspException: No getter method for property: "otherBean.MyMap(API).listElement" of bean: "MyBeanForm"
我该如何解决?
有效
<nested:iterate property="myMap" id="entry">
<bean:write name="entry" property="key"/>
<nested:iterate property="value" name="entry" id="obj">
<bean:write name="obj" property="name"/>
</nested:iterate>
</nested:iterate>