在做全局异常处理的时候,碰到重定向到全局错误页面
所谓隐藏参数无非是把参数放到了session中,再重定向后将该值清除
1、全局异常处理方法
@ExceptionHandler(value = Exception.class)
public ModelAndView exceptionHandle(RedirectAttributes redirectAttributes) {
ModelAndView modelAndView = new ModelAndView("redirect:/systemError");
redirectAttributes.addFlashAttribute("error", "错误信息");
return modelAndView;
}
2、重定向方法
@GetMapping("/systemError")
public ModelAndView systemError(@ModelAttribute("error") String error){
ModelAndView modelAndView = new ModelAndView("error");
modelAndView.addObject("error", error);
return modelAndView;
}