|
|
@@ -1,25 +1,34 @@
|
|
|
package com.izouma.awesomeAdmin.web;
|
|
|
|
|
|
+import org.apache.commons.io.IOUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.boot.web.servlet.error.ErrorController;
|
|
|
+import org.springframework.context.ApplicationContext;
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.ui.Model;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.servlet.ModelAndView;
|
|
|
+import org.springframework.web.servlet.View;
|
|
|
|
|
|
import javax.servlet.RequestDispatcher;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.io.IOException;
|
|
|
|
|
|
@Controller
|
|
|
public class AppErrorController implements ErrorController {
|
|
|
+ @Autowired
|
|
|
+ private ApplicationContext context;
|
|
|
+
|
|
|
@Override
|
|
|
public String getErrorPath() {
|
|
|
return "/error";
|
|
|
}
|
|
|
|
|
|
@RequestMapping("/error")
|
|
|
- public String handleError(HttpServletRequest request, Model model) {
|
|
|
+ public Object handleError(HttpServletRequest request, Model model) throws IOException {
|
|
|
Object status = request.getAttribute(RequestDispatcher.ERROR_STATUS_CODE);
|
|
|
-
|
|
|
if (status != null) {
|
|
|
int statusCode = Integer.parseInt(status.toString());
|
|
|
|