File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Iterate hashmap problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Iterate hashmap problem" Watch "Iterate hashmap problem" New topic

Iterate hashmap problem

david arnold
Ranch Hand

Joined: Apr 10, 2009
Posts: 133

I tried to iterate a hashmap in a arraylist and got exceptions: javax.servlet.ServletException: No getter method for property: "listCards" of bean: "categories"

In Action:


I already defined "getListCards" method, why do I get such exception?

Thanks for help!
Ankit Garg

Joined: Aug 03, 2008
Posts: 9466

How are you expecting to iterate over a method which returns a single object not a collection?? The getListCards method must return the entire HashMap for it to be iterated. Also the getter method must not take any arguments. To work with a single card, you can declare another getListCard(String key) method (like the one you have currently but only without the "s" in card as its returning a single card which is just a naming convention)...

SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
david arnold
Ranch Hand

Joined: Apr 10, 2009
Posts: 133
I see, thank you Ankit for pointing out the problem.

I agree. Here's the link:
subject: Iterate hashmap problem
jQuery in Action, 3rd edition