0

アノテーション @ExceptionHandler を使用するときに例外オブジェクトに入る方法はありますか?

これは私のコードです:

@ExceptionHandler(DataInputException.class)
    public ResponseEntity handleException(){
         return ResponseEntity
                    .status(HttpStatus.BAD_REQUEST)
                    .body("Entity contains null or forbidden values");
    }

特定のフィールドに関するカスタマイズされた情報を含むメッセージを返したいと思います。(そのため、エラー オブジェクトが必要です)。

4

1 に答える 1

3

例外を渡す

@ExceptionHandler(DataInputException.class)
public ResponseEntity handleException(DataInputException exception) {
于 2016-09-29T13:29:01.177 に答える