<?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: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/context https://www.springframework.org/schema/context/spring-context.xsd"> <!--spring的配置文件 声明组件扫描器--> <context:component-scan base-package="com.framework.twm.controller"/> <!--声明视图解析器;帮助处理视图 主要帮助我们处理重复的多余的冗余路径等--> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <!--前缀:指定试图文件的路径--> <property name="prefix" value="/WEB-INF/view/"/> <!--后缀,试图文件的扩展名--> <property name="suffix" value=".jsp"/> <!--表示所有的jsp文件--> </bean> <!--开启springMVC的注解支持--> <mvc:annotation-driven></mvc:annotation-driven> 它就相当于在 xml 中配置了: <!-- Begin --> <!-- HandlerMapping --> <bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping"></bean> <bean class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping"></bean> <!-- HandlerAdapter --> <bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter"></bean> <bean class="org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter"></bean> <bean class="org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter"></bean> <!-- HadnlerExceptionResolvers --> <bean class="org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver"></bean> <bean class="org.springframework.web.servlet.mvc.annotation.ResponseStatusExceptionResolver"></bean> <bean class="org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver"></bean> <!-- End --> </beans>