这里是我的FormBean: -JSR 303 Bean验证春季
public class LoginFormBean {
@NotEmpty
private String userId;
@NotEmpty
private String password;
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getPassword() {
return password;
}
public void setPassword(String pass) {
this.password = pass;
}
}
,并在我的message.properties文件我写: -
NotEmpty={0} must not empty.
它显示了我的错误消息:userId must not empty.
和password must not empty.
但我想要显示错误消息为User Id must not empty.
或'Password must not empty.'
我知道我可以在我的formBean中使用@NotEmpty(message="User Id must not empty")
,但我想同步消息,就好像我们需要更改消息一样,它的开销会小一些。
我搜索了JSR文档,但没有找到任何东西来替换我的属性名称userId
到User Id
在飞行中。请大家帮助我,从两天内就陷入困境。
如果这是不可能的,那么告诉我,如果没有,然后帮助我的东西替代。
感谢
沙姆斯
感谢您的回复,是的,我知道我可以像这样使用,但它仍然不是“可重复使用”。在这种情况下,我必须为属性文件中的每个属性创建一个新条目,即使我在多个bean中使用'userId'属性。 – Shams 2011-06-28 13:29:35