@Configuration
public class SeckillSentinelConfig implements BlockExceptionHandler {
@Override
public void handle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, BlockException e) throws Exception {
R error = R.error(BizCodeEnum.TO_MANY_REQUEST.getCode(), BizCodeEnum.TO_MANY_REQUEST.getMsg());
String s = JSON.toJSONString(error);
System.out.println("自定义的返回" + s);
httpServletResponse.setContentType("text/json;charset=utf-8");
httpServletResponse.getWriter().write(s);
}
}
低版本使用: