ControllerAdvice注意@、:クラスを作成し、プラス
二、@ exceptionHandlerの(値= Exception.class)
例外処理を作成し、方法は@ExceptionHandler(値= Exception.class)メモを追加する必要があり、この方法で例外を処理
第三に、例えば、
私たちは、最初に指定された時点でのRuntimeExceptionをスローする必要があります
catch (Exception e) {
LOGGER.error("密文加密失败"+e.getMessage(),e);
throw new RuntimeException("密文加密失败");
}
/**
* description 拦截未知的运行时异常
*
* @param e 1
* @return com.usthe.bootshiro.domain.vo.Message
*/
@ExceptionHandler(RuntimeException.class)
@ResponseStatus(HttpStatus.OK)
public Message notFoundException(RuntimeException e) {
LOGGER.error("运行时异常:",e);
return new Message().error(1111,"服务器开小差");
}