Can't get Hibernate Validator working with Spring MessageSource

后端 未结 5 972
耶瑟儿~
耶瑟儿~ 2021-02-09 17:02

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:00

    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}")

提交回复
热议问题