zoukankan      html  css  js  c++  java
  • 【SpringBoot】12 Web开发 Part3 SpringMVC扩展

    例如我们习惯于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,约定大于配置,不要搞特立独行!!!后续维护困难】


     
     
  • 相关阅读:
    当今世界最为经典的十大算法投票进行时
    HDU_1203 I NEED A OFFER!
    POJ_2352 Stars(树状数组)
    HDU_1231 最大连续子序列
    POJ_3264 Balanced Lineup(线段树练手题)
    【转】休息几分种,学几个bash快捷键
    HDU_1013 Digital Roots
    HDU_1381 Crazy Search
    POJ_2528 Mayor's posters(线段树+离散化)
    zoj_1610 Count tht Color
  • 原文地址:https://www.cnblogs.com/mindzone/p/12858802.html
Copyright © 2011-2022 走看看