How to retrieve value from linkedhashmap using iterators in Struts2…?

前端 未结 2 607
南笙
南笙 2021-01-26 18:18

I have function which return LinkedHashMap in Struts2 and i just came to know that we cannot use for loop in struts2 instead we have to use Iterators, and am new to struts

2条回答
  •  无人共我
    2021-01-26 18:46

    You should iterate over List of Map instead of Map of List


    Example :

    @Getter
    private List listOfMap = Lists.newArrayList();
    
    public String execute() {
    
        while (resultset.next()) {
            final Map map = Maps.newHashMap();
    
            map.put("manufId", resultset.getString("manufacturer_id"));
            map.put("manufLogo", resultset.getString("SUPPLIER_LOGO_IMAGE"));
            map.put("manufName", resultset.getString("MANUFACTURER_NAME"));
            map.put("manufURL", resultset.getString("MANUFACTURER_URL"));
    
            listOfMap.add(map);
        }
    
        return SUCCESS;
    }
    

    
      ${manufId}
      ${manufLogo}
      ${manufName}
      ${manufURL}
    
    

    The listOfMap also can use as a dataSource for Struts2 JasperReports Plugin.

提交回复
热议问题