从01开始 从01开始
首页
  • 计算机科学导论
  • 数字电路
  • 计算机组成原理

    • 计算机组成原理-北大网课
  • 操作系统
  • Linux
  • Docker
  • 计算机网络
  • 计算机常识
  • Git
  • JavaSE
  • Java高级
  • JavaEE

    • Ant
    • Maven
    • Log4j
    • Junit
    • JDBC
    • XML-JSON
  • JavaWeb

    • 服务器软件
    • Servlet
  • Spring
  • 主流框架

    • Redis
    • Mybatis
    • Lucene
    • Elasticsearch
    • RabbitMQ
    • MyCat
    • Lombok
  • SpringMVC
  • SpringBoot
  • 学习网课的心得
  • 输入法
  • 节假日TodoList
  • 其他
  • 关于本站
  • 网站日记
  • 友人帐
  • 如何搭建一个博客
GitHub (opens new window)

peterjxl

人生如逆旅,我亦是行人
首页
  • 计算机科学导论
  • 数字电路
  • 计算机组成原理

    • 计算机组成原理-北大网课
  • 操作系统
  • Linux
  • Docker
  • 计算机网络
  • 计算机常识
  • Git
  • JavaSE
  • Java高级
  • JavaEE

    • Ant
    • Maven
    • Log4j
    • Junit
    • JDBC
    • XML-JSON
  • JavaWeb

    • 服务器软件
    • Servlet
  • Spring
  • 主流框架

    • Redis
    • Mybatis
    • Lucene
    • Elasticsearch
    • RabbitMQ
    • MyCat
    • Lombok
  • SpringMVC
  • SpringBoot
  • 学习网课的心得
  • 输入法
  • 节假日TodoList
  • 其他
  • 关于本站
  • 网站日记
  • 友人帐
  • 如何搭建一个博客
GitHub (opens new window)
  • JavaSE

  • JavaSenior

  • JavaEE

  • JavaWeb

  • Spring

  • 主流框架

  • SpringMVC

  • SpringBoot

    • SpringBoot教程-尚硅谷

      • SpringBoot课程介绍
      • Spring和SpringBoot
      • HelloWorld
      • 了解自动配置原理
      • 底层注解-@Configuration详解
      • 底层注解-@Import导入组件
      • 底层注解-@Conditional条件装配
      • 原生配置文件引入-@ImportResource
      • 底层注解-配置绑定@ConfigurationProperties
      • 自动配置原理
      • 自动配置流程
      • Lombok简化开发
      • DevTools
      • Spring-Initailizr
      • 配置文件-Yaml用法
      • Web开发简介
        • 前言
        • 简介
      • web开发-静态资源规则于定制化
      • 静态资源配置原理
      • Rest映射及源码解析
      • 请求映射原理
      • 常用参数注解使用
      • MatrixVariable:矩阵变量
      • 各种类型参数解析原理
      • Servlet-API参数解析原理
      • Model、Map参数解析原理
      • 自定义对象参数绑定原理
      • 自定义Converter原理
      • 数据响应原理
      • 内容协商原理
      • 基于请求参数的内容原理
      • 自定义MessageConverter原理
      • Thymeleaf初体验
      • web实验-后台管理系统
      • web实验-抽取公共页面
      • web实验-遍历数据
      • 源码分析-视图解析器与视图
      • 拦截器-登录检查与静态资源放行
      • 拦截器的执行时机和原理
      • 单文件和多文件上传的使用
      • 文件上传原理
      • 错误处理机制
      • 错误处理-底层组件源码分析
      • 异常处理流程
      • 几种异常处理原理
      • Web原生对象注入
      • 嵌入式Servlet容器
      • 定制化原理
      • 数据库场景的自动配置分析和整合测试
      • 自定义方式整合Druid
      • 通过starter整合Druid
      • 整合Mybatis
      • 使用注解整合Mybatis
      • 整合MybatisPlus操作数据库
      • MybatisPlus-列表分页展示
      • 整合Redis
      • 单元测试-Junit5
      • 单元测试-断言机制
      • 单元测试-前置条件
      • 单元测试-嵌套测试
      • 单元测试-参数化测试
      • 指标监控-基本概念
      • 指标监控-配置EndPoint
      • 指标监控-可视化
      • 原理解析-Profile功能
      • 配置文件深入
      • 自定义Starter
      • SpringApplication初始化过程
      • SpringBoot完整启动过程
      • SpringBoot
  • Java并发

  • Java源码

  • JVM

  • 韩顺平

  • Java
  • Java
  • SpringBoot
  • SpringBoot教程-尚硅谷
2023-08-22
目录

Web开发简介

# 160.Web开发简介

接下来,我们就正式讲解web开发的场景   ‍

# 前言

该场景用的多,知识点多、细,底层原理复杂,因此我们讲的也多:

  • SpringMVC自动配置概览
  • 简单功能分析
  • 请求参数处理
  • 数据响应与内容协商
  • 视图解析与模板引擎
  • 拦截器
  • 异常处理
  • 原生Servlet组件
  • 嵌入式web容器
  • 定制化原理
  • .....

先讲怎么用,在讲原理

相关官方文档:

​​

‍

# 简介

首先,SpringBoot是框架的框架,底层仍然用的是SpringMVC,并且配置好了SpringMVC;

那么具体配置了什么呢?我们来看看:

Spring Boot provides auto-configuration for Spring MVC that works well with most applications.

The auto-configuration adds the following features on top of Spring’s defaults:

  • Inclusion of ContentNegotiatingViewResolver​ and BeanNameViewResolver​ beans.
  • Support for serving static resources, including support for WebJars (covered later in this document (opens new window))).
  • Automatic registration of Converter​, GenericConverter​, and Formatter​ beans.
  • Support for HttpMessageConverters​ (covered later in this document (opens new window)).
  • Automatic registration of MessageCodesResolver​ (covered later in this document (opens new window)).
  • Static index.html​ support.
  • Custom Favicon​ support (covered later in this document (opens new window)).
  • Automatic use of a ConfigurableWebBindingInitializer​ bean (covered later in this document (opens new window)).

‍

大意:

SpringBoot给SpringMVC,提供了自动配置,并且大多数场景下都能运作顺利。

自动配置添加了如下默认配置:

  • 配置了内容协商视图解析器和BeanName视图解析器
  • 支持静态资源(包括webjars)
  • 自动注册 Converter​,GenericConverter​,Formatter​
  • 支持 HttpMessageConverters​ (后来我们配合内容协商理解原理)
  • 自动注册 MessageCodesResolver​ (用于国际化,一般用的少)
  • 静态 index.html 页支持
  • 自定义 Favicon​(图标)
  • 自动使用 ConfigurableWebBindingInitializer​,(DataBinder负责将请求数据绑定到JavaBean上)

‍

也支持定制化:

If you want to keep those Spring Boot MVC customizations and make more MVC customizations (opens new window) (interceptors, formatters, view controllers, and other features), you can add your own @Configuration​ class of type WebMvcConfigurer​ but without @EnableWebMvc​.

If you want to provide custom instances of RequestMappingHandlerMapping​, RequestMappingHandlerAdapter​, or ExceptionHandlerExceptionResolver​, and still keep the Spring Boot MVC customizations, you can declare a bean of type WebMvcRegistrations​ and use it to provide custom instances of those components.

If you want to take complete control of Spring MVC, you can add your own @Configuration​ annotated with @EnableWebMvc​, or alternatively add your own @Configuration​-annotated DelegatingWebMvcConfiguration​ as described in the Javadoc of @EnableWebMvc​.

大意:

不用@EnableWebMvc注解,使用 @Configuration​ + WebMvcConfigurer​ 自定义规则(比如拦截器,格式化器,视图控制器)

声明 WebMvcRegistrations​ 改变默认底层组件

使用​ ​​@EnableWebMvc+@Configuration+DelegatingWebMvcConfiguration 全面接管SpringMVC​

在GitHub上编辑此页 (opens new window)
上次更新: 2023/8/23 10:10:57
配置文件-Yaml用法
web开发-静态资源规则于定制化

← 配置文件-Yaml用法 web开发-静态资源规则于定制化→

Theme by Vdoing | Copyright © 2022-2023 粤ICP备2022067627号-1 粤公网安备 44011302003646号
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式