I need to do this, with annotation, withouth using xml file.
< bean id="placeholderConfig" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" >
< property name="locations" >
< list >
< value >app.properties< / value >
< / list >
< / property >
< / bean >
And I need to call my property values in my jsp like ${test.name}
(where test.name is configured in app.properties)
Now I do this
@PropertySource(value="app.properties", ignoreResourceNotFound=true)
...
@Bean(name="placeholderConfig")
public static PropertySourcesPlaceholderConfigurer placeholderConfigurer(){
PropertySourcesPlaceholderConfigurer cfg = new PropertySourcesPlaceholderConfigurer();
cfg.setLocation(new ClassPathResource("app.properties"));
cfg.setIgnoreUnresolvablePlaceholders(true);
return cfg;
}
In this way i can access whith
@Value("${test.name}")
String name; //contain value of test.name configured in app.properties
But if i do ${test.name} in my jsp, this is not read. To let jsp read the value I have to do (in my java class)
@Value("${test.name}")
String name;
...
model.addObject("name", name);
There is a way to access directly to my property from my jsp, whit ${test.name}
code?