Spring(十)系统异常处理器

系统异常处理器  SimpleMappingExceptionResolver

发生异常的时候转到错误页面

1.需要一个类

2.配置文件:

 <context:component-scan base-package="cn.mvc.t12execption"></context:component-scan>

    <!--试图解析器-->
    <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix" value="/day01/"></property>
        <property name="suffix" value=".jsp"></property>
    </bean>

    <!--异常处理器-->
    <bean class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
        <property name="defaultErrorView" value="error"></property>
        <property name="exceptionAttribute" value="ex"></property>
    </bean>

  3.错误页面:

 

posted @ 2018-04-02 15:44  Gtr_Right  阅读(125)  评论(0编辑  收藏  举报