Spring全局异常捕捉类 注解@ControllerAdvice
package com.sicdt.sicsign.web.bill.controller; import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody; import com.sicdt.sicsign.bill.api.model.ModelAndResult; @ControllerAdvice
public class ExceptionInterceptorHandler {
@ExceptionHandler(RuntimeException.class)
@ResponseBody
public ModelAndResult interceptRuntimeException(Exception e){
return new ModelAndResult(false, "拦截到异常");
}
}