0
我在我的spring mvc項目中有兩個ControllerAdvices。方法級別的@ControllerAdvice
//return the json message
@ControllerAdvice(annotations = RestController.class)
public class AdviceRestController
//redirect to the error
@ControllerAdvice(annotations = Controller.class)
public class AdviceController
現在,我在@Controller註釋類中有一些@ResponseBody註釋方法。是否有方法級別的註釋,然後我可以在我的AdviceController中爲@ResponseBody註釋方法編寫方法。
即
//reoponsebody method only
@ReoponsebodyMethod
@ExceptionHandler({Exception.class})
@ResponseStatus(value = HttpStatus.INTERNAL_SERVER_ERROR)
public String handleIllegalStateException(Exception ex) {
//return son
}
Hi @Strelok,這已經很長時間了。我以前使用解決方法解決方案。我只想在Reoponsebody註釋的方法中捕獲異常。 – shuan