I was having some problem when trying to access the key value pairs in properties file using Spring MVC.
Here is where I stored the properties file: ../common/properties/AppResource.properties.
An example of key value pair in the file:
error.password.mismatch=Invalid userid and/or password, please try again
In my servlet.xml, I declared the following bean:
<bean name="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basename">
<value>classpath*:common/properties/*.properties</value>
</property>
In my controller, I am trying to access the key value pair:
} catch (UserNotFoundException e) {
model.addAttribute("errorMessage", "error.password.mismatch");
return "login";
}
In my JSP page, I am printing the error message:
<font class="errorClass"><form:errors path="errorMessage" /></font>
However, the message printed out was "error.password.mismatch" instead of referring to the text in properties file. Any ideas?