我是Spring MVC的新手。我有一个控制器捕获了一个异常,捕获异常后我想要重定向到error.jsp页面并显示异常消息(ex.getMessage())。我不想使用Spring的异常处理程序,而是要通过编程方式重定向到error.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
}