self_example/Spring/spring_exception_demo/src/main/resources/spring-mvc.xml

43 lines
1.7 KiB
XML

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
">
<!--1、mvc注解驱动-->
<mvc:annotation-driven/>
<!--2、配置视图解析器-->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/"/>
<property name="suffix" value=".jsp"/>
</bean>
<!--3、静态资源权限开放-->
<mvc:default-servlet-handler/>
<!--4、组件扫描 扫描Controller-->
<context:component-scan base-package="com.itheima.controller"/>
<!--配置异常处理器-->
<!-- <bean class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">-->
<!-- <property name="defaultErrorView" value="error"/>-->
<!-- <property name="exceptionMappings">-->
<!-- <map>-->
<!-- <entry key="java.lang.ClassCastException" value="error1"/>-->
<!-- <entry key="com.itheima.exception.MyException" value="error2"/>-->
<!-- </map>-->
<!-- </property>-->
<!-- </bean>-->
<!--自定义异常处理器-->
<bean class="com.itheima.resovler.MyExceptionResolver"/>
</beans>