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

狂风中的少年 提交于 2020-04-05 06:28:43

问题


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 ?


回答1:


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>


来源:https://stackoverflow.com/questions/60889028/how-to-iterate-over-mapstring-listmyobject-in-the-jsp-using-struts-tag-libr

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!