Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/349.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 访问exceptionhandler方法内部的错误对象_Java_Error Handling_Exception Handling_Exceptionhandler - Fatal编程技术网

Java 访问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时,有没有办法进入异常对象的内部

这是我的代码:

@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) {