Reputation: 11
I have two properties file in my application-
app.properties
level.user=username
easyDeploy_general.properties
user.update=Update
I have defined them in spring-servlet.xml
in below way
<bean id="messageSource"
class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="basenames">
<list>
<value>WEB-INF/resources/easyDeploy_general</value>
<value>WEB-INF/resources/app</value>
</list>
</property>
</bean>
Now,I want to access those property key value pair from my controller. How can I achieve these?
Upvotes: 1
Views: 969
Reputation: 388316
If your controller is annotated then you can use @Value
@Value("${level.user}")
private String levelUser;
@Value("${user.update}")
private String userUpdate;
If it is xml driven then
<bean id="" class="some.myController">
<property name="levelUser" value="${level.user}" />
<property name="userUpdate" value="${user.update}" />
</bean>
Upvotes: 2