David Parks David Parks - 1 year ago 102
Java Question

How to standardize and organize error messages with Hibernate Validator (running under Spring framework)

I'm learning Hibernate Validator. I see that I can add an error message text to any annotation.

But this seems like a bad way to handle error messages. It would be cleaner to return an error message ID and look up the message text in some resource file like a Properties file.

In this way I can later extend to other languages by swapping out the particular resource file; and the error messages are organized into one coherent location.

What's the best approach here with Hibernate Validator?

Answer Source

You might want to check this section in the manual for an approach of i18n error descriptions in Hibernate Validator.

There is another tutorial which might prove handy.


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download