gpt4 book ai didi

java.lang.NoSuchMethodException : userAuth. User.()

转载 作者:IT老高 更新时间:2023-10-28 13:05:24 24 4
gpt4 key购买 nike

我有带验证的类(class):

public class User {
@Size(min=3, max=20, message="User name must be between 3 and 20 characters long")
@Pattern(regexp="^[a-zA-Z0-9]+$", message="User name must be alphanumeric with no spaces")
private String name;

@Size(min=6, max=20, message="Password must be between 6 and 20 characters long")
@Pattern(regexp="^(?=.*[0-9])(?=.*[a-zA-Z])([a-zA-Z0-9]+)$", message="Password must contains at least one number")
private String password;

public User(String _name, String _password){
super();
name = _name;
password = _password;
}

public String getName(){
return name;
}

public String getPassword(){
return password;
}

public void setPassword(String newPassword){
password = newPassword;
}

}

当我验证值时,我收到了消息:

SEVERE: Servlet.service() for servlet osAppServlet threw exception
java.lang.NoSuchMethodException: userAuth.User.<init>()

问题出在哪里?

最佳答案

消息java.lang.NoSuchMethodException: userAuth.User.<init>()意味着有人试图在没有任何参数的情况下调用构造函数。添加默认构造函数应该可以解决这个问题:

public class User {

public User() {

}

..
}

关于java.lang.NoSuchMethodException : userAuth. User.<init>(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18023870/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com