在我的表单中,我使用javax.validation
@Size(max = 10, min = 9)
String myField;
并且在ValidationMessages.properties中我定义了我的自定义消息:
javax.validation.constraints.Size.message = Size should be between {min} and {max}
但现在我想要包含类似Size of {field} should be between {min} and {max}
是否可以使用此属性文件添加字段名称?
答案 0 :(得分:0)
只做
myfield.size.message = myField should be between {min} and {max}
并改变:
@Size(max = 10, min = 9)
String myField;
到
@Size(max = 10, min = 9, message = "{myfield.size.message}")
String myField;
或
message.size=should be between {min} and {max}
@Size(max = 10, min = 9, message = "myfield {message.size}")
String myField;