4
我是Spring MVC的新手。我捕获了异常,我想重定向到error.jsp页面并显示异常消息(ex.getMessage())后捕获异常的控制器。我不想使用Spring的异常处理程序,而是必须以编程方式重定向到error.jsp。从Spring MVC的控制器调用Jsp页面
@RequestMapping(value = "http/exception", method = RequestMethod.GET)
public String exception2()
{
try{
generateException();
}catch(IndexOutOfBoundsException e){
handleException();
}
return "";
}
private void generateException(){
throw new IndexOutOfBoundsException();
}
private void handleException(){
// what should go here to redirect the page to error.jsp
}
感谢爱德华。你是对的。它应该不是字符串,这种方式将起作用。感谢您的答复 – james01 2012-07-05 23:50:00