处理错误页面重定向问题
This commit is contained in:
parent
ab04fce0f7
commit
8b9888f4b5
@ -19,6 +19,7 @@ import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
@ -119,8 +120,8 @@ public class ResponseAdvice {
|
||||
}
|
||||
try {
|
||||
request.getSession().setAttribute("errorStackTraces", errorStackTraces);
|
||||
response.sendRedirect(String.format("%s/system-error", request.getContextPath()));
|
||||
} catch (IOException ioException) {
|
||||
request.getRequestDispatcher("/error/exception").forward(request, response);
|
||||
} catch (IOException | ServletException ioException) {
|
||||
ioException.printStackTrace();
|
||||
}
|
||||
return;
|
||||
|
@ -7,8 +7,6 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
@ -35,11 +33,6 @@ public class DefaultBaseController {
|
||||
@Autowired
|
||||
protected HttpServletResponse httpServletResponse;
|
||||
|
||||
@GetMapping("system-error")
|
||||
public ModelAndView error() {
|
||||
return new ModelAndView("error/error");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取请求参数
|
||||
*
|
||||
|
@ -0,0 +1,22 @@
|
||||
package ink.wgink.common.base;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
/**
|
||||
* @ClassName: ErrorExceptionController
|
||||
* @Description: 错误异常
|
||||
* @Author: wanggeng
|
||||
* @Date: 2021/10/19 9:58 上午
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@Controller
|
||||
public class ErrorExceptionController {
|
||||
|
||||
@GetMapping("error/exception")
|
||||
public ModelAndView error() {
|
||||
return new ModelAndView("error/exception");
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user