|
@@ -2,10 +2,6 @@
|
|
|
*/
|
|
*/
|
|
|
package com.uas.report.exception;
|
|
package com.uas.report.exception;
|
|
|
|
|
|
|
|
-import java.io.IOException;
|
|
|
|
|
-
|
|
|
|
|
-import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
-
|
|
|
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.http.HttpHeaders;
|
|
import org.springframework.http.HttpHeaders;
|
|
@@ -15,7 +11,6 @@ import org.springframework.ui.ModelMap;
|
|
|
import org.springframework.web.bind.annotation.ControllerAdvice;
|
|
import org.springframework.web.bind.annotation.ControllerAdvice;
|
|
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
|
|
|
|
|
|
|
-import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.uas.report.util.ExceptionUtils;
|
|
import com.uas.report.util.ExceptionUtils;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -47,24 +42,4 @@ public class ExceptionHandlerAdvice {
|
|
|
return new ResponseEntity<ModelMap>(map, headers, HttpStatus.INTERNAL_SERVER_ERROR);
|
|
return new ResponseEntity<ModelMap>(map, headers, HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * 处理错误
|
|
|
|
|
- *
|
|
|
|
|
- * @param response
|
|
|
|
|
- * @param status
|
|
|
|
|
- * @param message
|
|
|
|
|
- * @param ip
|
|
|
|
|
- * @throws IOException
|
|
|
|
|
- */
|
|
|
|
|
- public static void handleError(HttpServletResponse response, Integer status, String message, String ip)
|
|
|
|
|
- throws IOException {
|
|
|
|
|
- logger.error(message + ":" + ip);
|
|
|
|
|
- response.setHeader("Content-type", "text/html;charset=UTF-8");
|
|
|
|
|
- response.setStatus(status);
|
|
|
|
|
- JSONObject jsonObject = new JSONObject();
|
|
|
|
|
- jsonObject.put("success", false);
|
|
|
|
|
- jsonObject.put("message", message);
|
|
|
|
|
- response.getWriter().println(jsonObject);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
}
|
|
}
|