【发布时间】:2011-07-24 23:34:59
【问题描述】:
这是我的表单豆:-
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。请大家帮帮我,从两天开始就卡住了。
如果不可能,请告诉我,如果不能,请帮助我做些替代。
谢谢
假货
【问题讨论】:
标签: spring-mvc properties bean-validation