New to Spring-MVC.
I want to store two properties (uploadFolder=.., downloadFolder=..) in a .properties file and
access it in HomeController class (automatically created by the MVC template).
Can you please guide me how..
1) Created an app.properties file with the above and placed it under /src/main/resources. is this correct or should it go under /webapp/resources?
2) Placed a bean in servlet-context.xml in the following manner. is this correct?
<beans:bean id="messageSource"
class="org.springframework.context.support.ResourceBundleMessageSource">
<beans:property name="basename" value="app" />
</beans:bean>
3) Now how do I access this in Java controllers?
4) How do I access these in a JSP?
I can’t tell how much I will thank you.
There are a few different ways to do it. I do the following. In app context:
Make sure you have the following at the top of your file to include the “util” namespace:
I usually put my properties files in src/main/resources. As long as they’re on the classpath, you’re good. Then, in your controller, you can annotate your field/method with:
Then, in your JSP:
HTH. Let me know if you have any questions.