简体   繁体   中英

How to iterate over Map<String, List<MyObject>> in the jsp using struts tag library?

On Backend side I have a Map:

SortedMap<String, List<MyObject>> myMap = new TreeMap<>()

MyObject has private String name field with pulic getter and setter

On jsp I have:

<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>

But I see error:

Caused by: javax.servlet.jsp.JspException: No getter method for property: "otherBean.MyMap(API).listElement" of bean: "MyBeanForm"

How could I fix it ?

It works

<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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM