1

这是我的代码片段,

public class LoginAction extends ActionSupport {
     private String userId;
 private String password;
     ...........

     public void validate() {
    if (getUserId().length() == 0) {
        addFieldError("userId",getText("userId.required"));
    } 
    else if (!getUserId().equals("va1525252")) {
        addFieldError("userId", "Invalid User");
    }
    if (getPassword().length() == 0) {
        addFieldError("password",getText("password.required"));
    }
}

当 userId 字段为空时,我收到错误说Login Name is required我从未设置过这样的错误消息,那么这里有什么问题?

这是我们的 LoginAction.properties 文件,它与 LoginAction 类在同一个包中

password.required = Password is required
userId.required = UserId is required

这是我们点击提交时登录页面的屏幕截图,字段为空 登录页面

4

0 回答 0