私はSpring MVCが初めてです。例外をキャッチした後、error.jsp ページにリダイレクトして例外メッセージ (ex.getMessage()) を表示したいと考えています。プログラムで error.jsp にリダイレクトする必要があるため、Spring の Exception Handler を使用したくありません。
@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
}