This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Spring and the fly likes How to create and access properties without a properties file or class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "How to create and access properties without a properties file or class" Watch "How to create and access properties without a properties file or class" New topic
Author

How to create and access properties without a properties file or class

salvin francis
Ranch Hand

Joined: Jan 12, 2009
Posts: 917

I was browsing through the web and i came accross this:


You can also configure a java.util.Properties instance as:

The Spring container converts the text inside the <value/> element into a java.util.Properties instance by using the JavaBeans PropertyEditor mechanism. This is a nice shortcut, and is one of a few places where the Spring team do favor the use of the nested <value/> element over the value attribute style.

source : http://static.springsource.org/spring/docs/3.0.0.RC1/spring-framework-reference/html/ch03s04.html#beans-value-element


From what i understand, these are properties created without the use of properties file,
I tried to do the same:


and I tried to access in the following ways:
${myMappings.properties.myVariable}
Error: Could not resolve placeholder 'myMappings.properties.myVariable'

${myMappings.myVariable}
Error: Could not resolve placeholder 'myMappings.myVariable'


My Website: [Salvin.in] Cool your mind:[Salvin.in/painting] My Sally:[Salvin.in/sally]
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

try just myVariable. Since that is the name of your property.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
salvin francis
Ranch Hand

Joined: Jan 12, 2009
Posts: 917

I feel silly to have not tried that,
but it didnt work too

${myVariable}
Could not resolve placeholder 'myVariable'
 
jQuery in Action, 2nd edition
 
subject: How to create and access properties without a properties file or class
 
Similar Threads
Using PropertyPlaceholderConfigurer to read in external properties - not working
javax.servlet.ServletException: No adapter for handler
The chosen transaction strategy requires access to the JTA TransactionManager
REST web service return both XML or JSON
transaction rollbacks, but a record is inserted?