【发布时间】:2015-04-22 09:24:57
【问题描述】:
我正在尝试为我的 bean 验证实现自定义错误消息。
我已经用验证规则 @Size( min = 2, max = 40, message = "errors.firstName.size" ) 注释了我的字段 firstName。
在我的message.properties 中,我添加了一个消息密钥errors.firstName.size=First Name must be between {min} and {max} chars。然而,在我的 Thymeleaf 生成的视图中,只出现了消息键(如屏幕截图所示)。
【问题讨论】:
-
您可以为您的 thymeleaf HTML 页面添加代码吗?
-
这是
th:errors = "*{__${field}__}"视图中的部分。 -
不确定这个语法。您是否尝试过不进行预处理(例如
th:errors = "*{field}")?
标签: spring validation internationalization spring-boot thymeleaf