File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Spring and the fly likes how to get a collection object in spring Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Application Frameworks » Spring
Reply Bookmark "how to get a collection object in spring" Watch "how to get a collection object in spring" New topic
Author

how to get a collection object in spring

Samanthi perera
Ranch Hand

Joined: Jan 08, 2010
Posts: 510
this is my dog class


this is my xml



this is my cat class


this is my main class


when i run i get out put as follow


how to get cat objects from collection d??
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12612
It looks like you did. Or are you just confused about the java.util.Collection API?
Mark Secrist
Ranch Hand

Joined: Jul 01, 2003
Posts: 89
I think you've basically got it but the collection is returning a list of Cat objects that simply implement the base class Object's toString() method. If you override this method on the Cat class and print something more to your liking then you should be good to go.

BTW - this is a Java problem, not necessarily a Spring problem.

Also, if you want your 3 cat instances to have any kind of name when they are printed out, you might want to modify your bean definitions as follows

Or... even better if you add

to the <beans> definition then you can do the following

 
IntelliJ Java IDE
 
subject: how to get a collection object in spring
 
Threads others viewed
Dout in Around Advice
how to set getting input from user
Spring with generics
method injection problem
where is the pointcut in this example
IntelliJ Java IDE