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


     
     
  • 相关阅读:
    和至少为 K 的最短子数组
    使用VS code编写C++无法实时检测代码的解决办法
    anaconda安装VSCODE后,python报错
    神经网络中sigmod函数和tanh函数的区别
    获取本机IP
    windows C++捕获CMD命令输出
    windows下面生成 dump
    windows 控制台命令输出 捕获
    不使用PEM 文件建立SSL通道
    OpenSSL socket 服务端
  • 原文地址:https://www.cnblogs.com/mindzone/p/12858802.html
Copyright © 2011-2022 走看看