Below is my spring configuration file:
<bean class="com.web.handler.CustomSimpleMappingExceptionResolver" >
<property name="exceptionMappings">
<props>
<prop key="java.lang.Throwable">error</prop>
</props>
</property>
</bean>
Class 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");
}
My web.xml has no error page. I am looking to show different view according to my logic in resolveException().
In CustomSimpleMappingExceptionResolver class resolveException() is not being called in case of 404.
Set error page in web.xml
your error page will redirect as soon as it opened.
There should be a request mapping in your controller to handle error.htm request.