[SpringBoot2]web场景_SpringBoot2_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.
○ 内容协商视图解析器和BeanName视图解析器
● Support for serving static resources, including support for WebJars (covered later in this document)).
○ 静态资源(包括webjars)
● Automatic registration of Converter, GenericConverter, and Formatter beans.
○ 自动注册 Converter,GenericConverter,Formatter
● Support for HttpMessageConverters (covered later in this document).
○ 支持 HttpMessageConverters (后来我们配合内容协商理解原理)
● Automatic registration of MessageCodesResolver (covered later in this document).
○ 自动注册 MessageCodesResolver (国际化用)
● Static index.html support.
○ 静态index.html 页支持
● Custom Favicon support (covered later in this document).
○ 自定义 Favicon
● Automatic use of a ConfigurableWebBindingInitializer bean (covered later in this document).
○ 自动使用 ConfigurableWebBindingInitializer ,(DataBinder负责将请求数据绑定到JavaBean上)
If you want to keep those Spring Boot MVC customizations and make more MVC customizations (interceptors, formatters, view controllers, and other features), you can add your own @Configuration class of type WebMvcConfigurer but without @EnableWebMvc.
不用@EnableWebMvc注解。使用 @Configuration + WebMvcConfigurer 自定义规则

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. 声明
WebMvcRegistrations 改变默认底层组件

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+DelegatingWebMvcConfiguration
全面接管SpringMVC

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/308774.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

[SpringBoot2]web场景_静态资源规则与定制化

静态资源目录 只要静态资源放在类路径下: called /static (or /public or /resources or /META-INF/resources 访问 : 当前项目根路径/ 静态资源名 原理: 静态映射/**。 请求进来,先去找Controller看能不能处理。不能处理的所有请…

【Ids4实战】最全的 v4 版本升级指南

(恰似一江春水向东流)最近听说IdentityServer4从v3升级到v4了,其实很简单,就是nuget包升级一下的事儿,不过没想到涉及到的内容还挺多,要不然也不会直接从3.1直接蹦到4.0,这么大的跨度&#xff0…

你真的清楚DateTime in C#吗?

DateTime,就是一个世界的大融合。日期和时间,在我们开发中非常重要。DateTime在C#中,专门用来表达和处理日期和时间。本文算是多年使用DateTime的一个总结,包括DateTime对象的整体应用,以及如何处理不同的区域、时区、…

【翻译】.NET 5中的性能改进

在.NET Core之前的版本中,其实已经在博客中介绍了在该版本中发现的重大性能改进。 从.NET Core 2.0到.NET Core 2.1到.NET Core 3.0的每一篇文章,发现谈论越来越多的东西。然而有趣的是,每次都想知道下一次是否有足够的意义的改进以保证再发表…

在安装keepalived出现问题:需要:libmysqlclient.so.18

在安装keepalived出现问题: # yum install keepalived -y错误:软件包:1:net-snmp-agent-libs-5.7.2-48.el7_8.1.x86_64 (updates)需要:libmysqlclient.so.18(libmysqlclient_18)(64bit) 错误:软件包:1:net…

[SpringSecurity]框架概述

概要 Spring 是非常流行和成功的 Java 应用开发框架,Spring Security 正是 Spring 家族中的 成员。Spring Security 基于 Spring 框架,提供了一套 Web 应用安全性的完整解决方 案。 正如你可能知道的关于安全方面的两个主要区域是“认证”和“授权”&a…

[译]使用DOT语言和GraphvizOnline来可视化你的ASP.NETCore3.0终结点01

这是系列文章中的第一篇:使用GraphvizOnline可视化ASP.NETCore3.0终结点。.第1部分-使用DOT语言来可视化你的ASP.NETCore3.0终结点(本文)第2部分-向ASP.NET Core应用程序添加终节点图第3部分-使用ImpromptuInterface创建一个自定义的DfaGraphWriter,以便…

.NET Core CLI 的性能诊断工具介绍

前言开发人员的.NET Core项目上线后,经常会出现各种问题,内存泄漏,CPU 100%,处理时间长等, 这个时候就需要快速并准确的发现问题,并解决问题, 除了项目本身的日志记录外,NET Core 为…

[SpringSecurity]HelloWorld入门案例

入门案例 第一步 创建springboot工程 第二步 引入相关依赖 <dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><dependency><groupId>org.springfram…

ASP.NET Core静态文件处理源码探究

前言静态文件&#xff08;如 HTML、CSS、图像和 JavaScript&#xff09;等是Web程序的重要组成部分。传统的ASP.NET项目一般都是部署在IIS上&#xff0c;IIS是一个功能非常强大的服务器平台&#xff0c;可以直接处理接收到的静态文件处理而不需要经过应用程序池处理&#xff0c…

[SpringSecurity]基本原理_过滤器链

SpringSecurity 本质是一个过滤器链&#xff1a; 从启动是可以获取到过滤器链&#xff1a; org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFil ter org.springframework.security.web.context.SecurityContextPersistenceFilter org.s…

通过Windows Visual Studio远程调试WSL2中的.NET Core Linux应用程序

最近两天在Linux中调试.NET Core应用程序&#xff0c;同时我发现在Linux中调试.NET Core应用程序并不容易。一直习惯在Visual Studio中进行编码和调试。现在我想的是可以简单快速的测试.NET Core应用在Linux。所以通过本篇文章我们能了解到如何在Windows中使用Visual Studio进行…

[SpringSecurity]基本原理_过滤器加载过程

过滤器如何进行加载的&#xff1f; 1.使用SpringSecurity配置过滤器 DelegatingFilterProxy 其中上面的getTargetBeanName()得到的名字是FilterChainProxy 找到FilterChainProxy这个类中的doFilter方法 最后两张图片里面的代码表示&#xff1a; 用了一个增强for循环和getFi…

[SpringSecurity]基本原理_两个重要的接口_UserDetailsService接口和PasswordEncoder接口

UserDetailsService接口 当什么也没有配置的时候&#xff0c;账号和密码是由 Spring Security 定义生成的。而在实际项目中 账号和密码都是从数据库中查询出来的。 所以我们要通过自定义逻辑控制认证逻辑。 如果需要自定义逻辑时&#xff0c;只需要实现 UserDetailsService 接…

.NET 开源项目 StreamJsonRpc 介绍[下篇]

阅读本文大概需要 9 分钟。大家好&#xff0c;这是 .NET 开源项目 StreamJsonRpc 介绍的最后一篇。上篇介绍了一些预备知识&#xff0c;包括 JSON-RPC 协议介绍&#xff0c;StreamJsonRpc 是一个实现了 JSON-RPC 协议的库&#xff0c;它基于 Stream、WebSocket 和自定义的全双工…

ASP.NET Core Blazor 初探之 Blazor Server

上周初步对Blazor WebAssembly进行了初步的探索(ASP.NET Core Blazor 初探之 Blazor WebAssembly)。这次来看看Blazor Server该怎么玩。Blazor ServerBlazor 技术又分两种&#xff1a;Blazor WebAssemblyBlazor ServerBlazor WebAssembly上次已经介绍过了&#xff0c;这次主要来…

[SpringSecurity]web权限方案_用户认证_设置用户名密码

设置登陆的用户名和密码 第一种方式&#xff1a;通过配置文件 spring.security.user.nameatguigu spring.security.user.passwordatguigu第二种方式&#xff1a;通过配置类 package com.atguigu.securitydemo1.config;import org.springframework.context.annotation.Bean; i…

更优雅的在 Xunit 中使用依赖注入

Xunit.DependencyInjection 7.0 发布了Intro上次我们已经介绍过一次大师的 Xunit.DependencyInjection 在 Xunit 中使用依赖注入 &#xff0c;最近大师完成了 7.0 的重构并且已经正式发布&#xff0c;已经可以直接安装使用了7.0 为我们带来了更好的编程体验&#xff0c;在 6.x…

[SpringSecurity]web权限方案_用户认证_查询数据库完成认证

#mysql 数据库连接 spring.datasource.driver-class-namecom.mysql.cj.jdbc.Driver spring.datasource.urljdbc:mysql://localhost:3306/demo?serverTimezoneUTC spring.datasource.usernameroot spring.datasource.passwordrootpackage com.atguigu.securitydemo1.config;i…