This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Spring and the fly likes Inject hashmap into controller Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Inject hashmap into controller" Watch "Inject hashmap into controller" New topic
Author

Inject hashmap into controller

Gilbert Jones
Greenhorn

Joined: Dec 15, 2011
Posts: 1
I'm pretty new to Spring. I'm trying to inject a hashmap defined in a properties file into a field in a controller defined with @controller annotation. I'm not sure how to do this, so any suggestions would be welcome.

I also tried to define the keys and values directly in the spring config file, they were injected correctly into the class initially, but the map was wiped out since the controller was recreated through the controller annotation.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Inject hashmap into controller