当前位置: 代码迷 >> 综合 >> springmvc中SimpleMappingException的使用及配置
  详细解决方案

springmvc中SimpleMappingException的使用及配置

热度:100   发布时间:2023-10-26 09:02:27.0

SimpleMappingExceptionResolver是用来处理框架产生的异常,我们可以配置产生异常时转向的页面及异常返回的属性名等信息,具体的配置如下是springmvc配置文件中的配置:

<!-- 配置SimpleMappingExceptionResolver异常处理 --><bean class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver"><property name="exceptionAttribute" value="exception"></property><property name="exceptionMappings"><props><prop key="java.lang.ArrayIndexOutOfBoundsException">error</prop></props></property></bean>

其中exceptionAttibute属性是异常信息返回到页面上的属性名:默认为exception,可以在SimpleMappingExceptionResolver类中看到

exceptoinMappings中配置的是具体发生的异常映射到的视图

  相关解决方案