下面是我的Spring配置文件:的SimpleMappingExceptionResolver不解決404
<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()
顯示不同的觀點。
在resolveException()
CustomSimpleMappingExceptionResolver
類不被稱爲404
重定向給出了一個HTTP狀態代碼404。春天是否也這樣做? – pshirishreddy
檢查您的網址是否正確,如html或htm。 –