我需要找到一种方法来捕获异常并将它们抛出到jsp页面
public class someController
{
@ExceptionHandler(Exception.class)
@ResponseBody
public void handleException(Exception exception,HttpServletRequest request, HttpServletResponse response)
{
//how do I use this function to get exceptions and send them to
//testModelView url below
}
@GET
@Path("/testModelAndView")
public ModelAndView resolveException()
{
ModelAndView mav = null;
mav = new ModelAndView("/view.jsp");
mav.addObject("/support/500.jsp", "Blah");
return mav;
}
答案 0 :(得分:0)
您的异常处理程序方法可以返回ModelAndView。类似于:
@ExceptionHandler(TAAException.class)
public ModelAndView handleMyException(Exception exception) {
logger.fatal(exception);
ModelAndView mav = null;
mav = new ModelAndView("/view.jsp");
mav.addObject("/support/500.jsp", "Blah");
return mav;
return modelAndView;
}