I've tried to iterate the variable of map type in jsp .. but the result page shows nothing
product details is of type Map<String,String>
//Action
public String execute() {
productDetails = displayServiceDao.fetchProductDetailsService( product );}
public Map<String , String> getProductDetails() {
return productDetails;
}
public void setProductDetails( Map<String , String> productDetails ) {
this.productDetails = productDetails;
}
//jsp
<s:iterator var="studentEntry" value="productDetails.entrySet()">
<s:property value="%{#studentEntry.getKey()}"/>
<s:property value="%{#studentEntry.getValue()}"/>
</s:iterator>
Note:i am not adding values to map in action class..i add it through the return value of a function
I think you need to decide what you want to do with the keys and values in your map. You could do:
<s:iterator value = "productDetails" >
<s:property value="key"/>
<s:property value="value"/>
</s:iterator>
Nb this will iterate over the entrySet of you map and use a Map.Entry object which contains key and value properties.
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.