Can't get Hibernate Validator working with Spring MessageSource

后端 未结 5 694
北荒
北荒 2021-02-09 17:39

I\'m trying to get Hibernate Validator setup to use messages from a Spring MessageSource. I have the following setup in my messages-context.xml:

<         


        
5条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-09 18:04

    It's because Hibernate validator is looking at another place for the error message resolver.

    For the easiest thing to make it works, I think you can create a file name "ValidationMessages.properties" and put it in your classpath folder. Then put the error messages into that file (got from validation_errors_en_GB.properties)

    By the way, the brackets are required when specifying error messages in model classes (message="{validation.too.long}")

提交回复
热议问题