SimpleMappingExceptionResolver统一管理异常

原创
小哥 3年前 (2022-10-27) 阅读数 73 #大杂烩

SimpleMappingExceptionResolver 类,该类实现HandlerExceptionResolver接口,只有在需要时才需要使用可以声明节点,如下所示:

Xml代码

  1. <bean class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
  2. <property name="defaultErrorView" value="error">
  3. <property name="exceptionAttribute" value="ex">
  4. <property name="exceptionMappings">
  5. <prop key="IOException">error/ioexp
  6. <prop key="java.sql.SQLException">error/sqlexp

通过SimpleMappingExceptionResolver我们可以将不同的异常映射到不同的jsp第页(exceptionMappings属性配置),我们还可以为所有异常指定默认异常。

版权声明

所有资源都来源于爬虫采集,如有侵权请联系我们,我们将立即删除

热门