Announcement Announcement Module
No announcement yet.
ValidationUtils not finding error msgs in properties file Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • ValidationUtils not finding error msgs in properties file

    I'm building a simple web app that uses Spring MVC and validation. I want an error message to be displayed from a properties file if validations for fields fail. However for some reason Spring is not finding my properties file error messages. It is, however, displaying the default error message in my validator code.

    Here is the relevant code:

    public RegisterStudentController extends SimpleFormController
    // wired to use the StudentValidator class
    (placed in WEB-INF/classes directory to be in classpath). Number Required <<--- ERROR MSG I WANT!
    public void validate (Object command, Errors errors)
    "Enter a Phone Number");

    <spring:bind path="student.phoneNumber">
    <td>Phone Number</td>
    <td><input type="text" name="phoneNumber"></td>
    <font color="red"><c:out value="${status.errorMessage}"/></font>

    The problem is that I get the default error Message "Enter a Phone Number" instead of the message from the properties file "Phone Number Required".

    Any ideas on why Spring is not finding my properties file? Do I have to configure the location of the properties file for Spring somewhere?

    Thanks in advance.

  • #2

    Never mind, I found the problem. The following has to be in the spring config file:

    <bean id="messageSource" class=" eBundleMessageSource">
    <property name="basename"><value>messages</value></property>