分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 网页技术

EnableWebMvc vs WebMvcConfigurationSupport

发布时间:2023-09-06 02:02责任编辑:熊小新关键词:Web

EnableWebMvc vs WebMvcConfigurationSupport

  • spring doc解释
    • WebMvcConfigurationSupport: This is the main class providing the configuration behind the MVC Java config. It is typically imported by adding @EnableWebMvc to an application @Configuration class

    • @EnableWebMvc
      • To customize the imported configuration, implement the interface WebMvcConfigurer and override individual methods
      • If WebMvcConfigurer does not expose some more advanced setting that needs to be configured consider removing the @EnableWebMvc annotation and extending directly from WebMvcConfigurationSupport or DelegatingWebMvcConfiguration
      • // 使用@EnableWebMvc注解会覆盖自定义的WebMvcConfigurationSupport配置
  • 二者的共同点
    • 都是为了配置MVC
  • 二者的区别
    • @EnableWebMvc注解的实现是基于WebMvcConfigurationSupport,详见@EnableWebMvc的doc
    • 三种应用形式只能选其一,如果自定义的WebMvcConfigurationSupport与@EnableWebMvc共同存在,则自定义的WebMvcConfigurationSupport配置会被覆盖
      • 自定义(高级模式): 继承WebMvcConfigurationSupport
      • 自定义(极简模式): @EnableWebMvc注解+实现WebMvcConfigurer接口
      • 默认模式: 使用@EnableWebMvc注解

EnableWebMvc vs WebMvcConfigurationSupport

原文地址:https://www.cnblogs.com/tao_/p/9265283.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved