Announcement Announcement Module
No announcement yet.
Custom bind error messages. Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Custom bind error messages.

    I've searched the forum, but I think this is a bit to simple so no one has come right out and said it yet. Basicly, when my date binding fails, how do I display a pretty message instead of the default verbose one? I think I have to put a .properties file somewhere, I just don't know where or what format to use. Thanks!

  • #2
    Take a look at the Javadoc for org.springframework.validation.DefaultMessageCodes Resolver.

    There are example messages that handle improperly entered dates in Petclinic's

    The Petclinic source is in the samples/petclinic dir of the download.


    • #3
      So, I've got a file in WEB-INF\classes with one line:

      typeMismatch=invalid date

      but whatever is supposed to be reading it, isn't. I've looked at the petstore source, and it looks like it works for them by merely having the file exist in that directory. Is there anything else I need to do?


      • #4
        You have to define a messageSource bean in your context. In the sample app, it is defined in petclinic-servlet.xml

        	<bean id="messageSource" class="">
        		<property name="basename"><value>messages</value></property>
        see also :



        • #5
          Yea, I found that and added the bean definition, copy and paste, to my application context. I'm wondering if I just have my file in the wrong place.