1、 注解开发springmvc ![在这里插入图片描述](https://img-blog.csdnimg.cn/742efd494f7e4038931877219cd145c9.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBAbGFuNTg0NDMzNDEx,size_20,color_FFFFFF,t_70,g_se,x_16)
springmvc-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:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
https://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
https://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/mvc
https://www.springframework.org/schema/mvc/spring-mvc.xsd"
>
<!--自动扫描包,让指定包下的注解生效,由IOC容器统一管理-->
<context:component-scan base-package="com.lan.controller"/>
<!--让spring mvc不处理静态资源-->
<mvc:default-servlet-handler/>
<!--支持mvc注解驱动:加了这个可以省略处理器映射器和处理器适配器的配置-->
<mvc:annotation-driven/>
<!--视图解析器-->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver" id="InternalResourceViewResolver">
<!--前缀-->
<property name="prefix" value="/WEB-INF/jsp/"/>
<!--后缀-->
<property name="suffix" value=".jsp"/>
</bean>
</beans>
2、实现Controller接口的方式缺点
3、使用注解@Controller:返回一个视图解析器,代表这个类会被spring接管
jsp页面根据不同的url地址被复用了
视频地址