• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

Reading properties file in spring mvc 3.0

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I am using Spring mvc 3.0 (Annotations). I am having a propert file like this

abc.properties

a = abc
b = bcd
c = cde

in my controller i am having a method getName(key) it has to return abc, bcd,cde ... according to the key.
i am not able to read the properties file
Tell me the steps to read the properties file.
can anyone please solve my problem as i am very new to spring framework.

Thanks in Advance.
 
Ranch Hand
Posts: 1376
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

You can simply use System.properties() method to load a properties file. then use it in your method to fetch key-value pairs. You will not require Spring MVC concept here

~ abhay

 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In your xml configuration use

<util:properties id="somthing" location="locationOfYourPropertiesFile">

then inject it into your controller class

Now your controller class will have the Properties object that you can call the getProperty() method on passing in the key.

Mark
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic