package cn.com.goldenwater.dcproj.controller.system; import cn.com.goldenwater.core.web.BaseResponse; import lombok.extern.slf4j.Slf4j; import org.springframework.boot.web.servlet.error.ErrorController; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @Slf4j @RestController public class HttpErrorController implements ErrorController { private final static String ERROR_PATH = "/error"; @ResponseBody @RequestMapping(path = ERROR_PATH ) public BaseResponse error(HttpServletRequest request, HttpServletResponse response){ BaseResponse result = new BaseResponse(); result.setCode(response.getStatus()); result.setData("系统检查异常,请联系管理员 :"+response.getStatus()); result.setMessage("系统检查异常,请联系管理员 :"+response.getStatus()); result.setPath(request.getRequestURI()); result.setSuccess(false); return result; } @Override public String getErrorPath() { return ERROR_PATH; } }