【发布时间】:2011-07-24 20:08:51
【问题描述】:
我似乎遇到了 Spring 的限制 - 我有一个简单的案例要处理 - 我正在模拟服务方法的异常:
@RequestMapping( method = RequestMethod.POST )
public String register( @RequestParam( "mail" ) String mail ){
throw new IllegalStateException();
}
并尝试通过以下方式处理新请求:
@RequestMapping( value = "/exception_location" )
@ExceptionHandler( IllegalStateException.class )
public String handleException( IllegalStateException ex ){
return "exception_view";
}
我的 web.xml:
<error-page>
<exception-type>java.lang.IllegalStateException</exception-type>
<location>/exception_location</location>
</error-page>
发生的情况是,handleException 确实被触发了,但异常视图没有在客户端上呈现。 Spring配置OK还是不需要web.xml中的条目?我是否遗漏了一些可能导致处理程序没有被调用的原因? 任何反馈表示赞赏。 谢谢。
【问题讨论】:
标签: java model-view-controller spring exception view