web xml
<error-page>
<error-code>403</error-code>
<location>/support/error.jsp</location>
</error-page>
<error-page>
<error-code>404</error-code>
<location>/support/error.jsp</location>
</error-page>
<error-page>
<error-code>405</error-code>
<location>/support/error.jsp</location>
</error-page>
<error-page>
<error-code>500</error-code>
<location>/support/error.jsp</location>
</error-page>
<error-page>
<exception-type>java.lang.Exception</exception-type>
<location>/support/error.jsp</location>
</error-page>
<error-page>
<exception-type>java.lang.Throwable</exception-type>
<location>/support/error.jsp</location>
</error-page>--我试图将所有异常和错误映射到一个页面(error.jsp)。如果可能的话,我可以像这样配置spring吗?
发布于 2011-11-14 18:42:55
看看如何使用SimpleMappingExceptionResolver。你可以把它看作是Exception的一个博客,下面是一个更多关于它的博客。
发布于 2011-11-16 10:19:44
<bean class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
<property name="exceptionMappings">
<props>
<prop key="java.lang.Exception">serviceFault</prop>
</props>
</property>
<property name="defaultErrorView" value="serviceFault" />
</bean>https://stackoverflow.com/questions/8126401
复制相似问题