我接到一个电话
public Test postTest(@RequestBody Test test) {
}
public class Test {
@JsonProperty("EMAIL_ADDRESS")
@NotNull(message = "EMAIL_ADDRESS_NOT_NULL")
@Size(min = 1, message = "EMAIL_ADDRESS_NOT_EMPTY")
@Email(flags = Flag.CASE_INSENSITIVE, message = "EMAIL_INVALID")
private String emailAddress;
public ForgetPassword(
@NotNull(message = "EMAIL_ADDRESS_NOT_NULL") @Size(min = 1,
message = "EMAIL_ADDRESS_NOT_EMPTY") @Email(flags =
Flag.CASE_INSENSITIVE,
message = "EMAIL_INVALID") String emailAddress) {
super();
this.emailAddress = emailAddress;
}
public String getEmailAddress() {
return emailAddress;
}
public void setEmailAddress(String emailAddress) {
this.emailAddress = emailAddress;
}
}
我错过了默认的构造器,当我试图发帖时,它一直在返回错误的请求。如果我添加默认构造函数,它就会工作。它甚至不会抛出堆栈跟踪。我正在使用自定义模板发送回中的响应。我正在重写badrequestexception以发回自定义消息。
@ResponseStatus(HttpStatus.BAD_REQUEST)
public class BadRequestException extends RuntimeException {
public BadRequestException(String message) {
super(message);
}
}
有什么方法我应该重写来捕获这些异常。我想知道为什么出了问题,并且能够看到堆栈的错误。