日期:2014-05-17 浏览次数:20616 次
public class BaseExceptionHandler implements HandlerExceptionResolver {
@Override
public ModelAndView resolveException(HttpServletRequest request,
HttpServletResponse response, Object handler, Exception ex) {
response.setStatus(HttpStatus.BAD_REQUEST.value());//返回 400 错误
if (ex instanceof BaseException) {//自定义 RtuploadException,直接返回
return JsonView.Render(ex, response);
} else {//非自定义 RtuploadException,返回新 RtuploadException 实例
return JsonView.Render(new BaseException(GlobalConstant.ERROR_CODE_9000), response);
}
}
}