以下は私の春の設定ファイルです:
<bean class="com.web.handler.CustomSimpleMappingExceptionResolver" >
<property name="exceptionMappings">
<props>
<prop key="java.lang.Throwable">error</prop>
</props>
</property>
</bean>
クラスCustomSimpleMappingExceptionResolver
public class CustomSimpleMappingExceptionResolver extends SimpleMappingExceptionResolver{
@Override
public ModelAndView resolveException(HttpServletRequest request,
HttpServletResponse response, Object handler, Exception ex) {
if(int a = 1)
return new ModelAndView("ViewName1");
else
return new ModelAndView("ViewName2");
}
私web.xml
のエラーページはありません。のロジックに従って、さまざまなビューを表示しようとしていresolveException()
ます。
404の場合、クラス内は呼び出されていませんCustomSimpleMappingExceptionResolver
。resolveException()