spring /error接口

  @RequestMapping(value = "/error", method = RequestMethod.GET)
  public String error() {
    int i = 1 / 0;
    return "error";
  }

  @RequestMapping(value = "/error1", method = RequestMethod.GET)
  public String sleep() {
    try {
      Thread.sleep(1000);
      int i = 1 / 0;
    } catch (InterruptedException e) {
      e.printStackTrace();
    }
    return "error1";
  }

请求/error1接口,因为该接口抛异常,所以最终会走到/error接口上,这与spring的错误处理策略有关

你可能感兴趣的:(JAVA)