Java 访问exceptionhandler方法内部的错误对象
当使用注解@ExceptionHandler时,有没有办法进入异常对象的内部 这是我的代码:Java 访问exceptionhandler方法内部的错误对象,java,error-handling,exception-handling,exceptionhandler,Java,Error Handling,Exception Handling,Exceptionhandler,当使用注解@ExceptionHandler时,有没有办法进入异常对象的内部 这是我的代码: @ExceptionHandler(DataInputException.class) public ResponseEntity handleException(){ return ResponseEntity .status(HttpStatus.BAD_REQUEST) .body("Enti
@ExceptionHandler(DataInputException.class)
public ResponseEntity handleException(){
return ResponseEntity
.status(HttpStatus.BAD_REQUEST)
.body("Entity contains null or forbidden values");
}
我希望已返回消息,以包含有关特定字段的自定义信息。(这就是我需要错误对象的原因)。传入异常
@ExceptionHandler(DataInputException.class)
public ResponseEntity handleException(DataInputException exception) {
传入异常
@ExceptionHandler(DataInputException.class)
public ResponseEntity handleException(DataInputException exception) {