Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Iterate hashmap problem

 
david arnold
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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:


In JSP:


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

Thanks for help!
 
Ankit Garg
Sheriff
Posts: 9528
32
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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)...
 
david arnold
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I see, thank you Ankit for pointing out the problem.

Regards,
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic