dispatcher-servlet.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:p="http:// www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
">
<context:component-scan base-package="org.springframework.samples.petclinic.web"/>
//用到注解就要用这个,所以必须写
<!-- 开启springmvc注解 -->
<mvc:annotation-driven></mvc:annotation-driven>
<!-- 寻找spingmvc相关注解的类 -->
//所有控制器的包,固定格式
<context:component-scan base-package="com.tedu.controller"></context:component-scan>
</beans>
原文:https://www.cnblogs.com/yangjingru/p/13693083.html