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 フィールドが空の場合、ログイン名が必要であるというエラーが表示されます。そのようなエラー メッセージを設定したことがないので、ここで何が問題なのですか?

これは、LoginAction クラスと同じパッケージにある LoginAction.properties ファイルです。

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

これは、フィールドが空の状態で送信をクリックしたときのログイン ページのスクリーンショットです。 ログインページ

4

0 に答える 0