例如我们习惯于SSM的xml配置,
这是使用MVC的容器跳转方式
<?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" 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 " > <mvc:view-controller path="/hello" view-name="success" /> <mvc:interceptors> <mvc:interceptor> <mvc:mapping path="/hello"/> <bean /> </mvc:interceptor> </mvc:interceptors> </beans>
编写一个配置类继承WebMVC适配器类
注意!不能注解@EnableWebMvc
这样可以用这个方法一次处理若干个这样只是需要转发的功能
然而这个类在新版被标注为过时的类,在新版又改为实现这个接口即可
接管SpringMVC:
大概的意思就是这样,就是为什么不要注解@EnableWebMvc,SpringBoot默认配置所有东西
如果你不想SpringBoot接管MVC的配置,就可以打上这个注解,全盘自己接管Mvc
【所有配置好的Web场景全部失效】
- 默认的静态资源配置失效
- 不激活内置的转发中心
- 不激活编码过滤器
- 不激活隐藏协议方法过滤器
【不建议全面接管MVC,约定大于配置,不要搞特立独行!!!后续维护困难】