下面是我的spring配置文件:
<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()