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:
ContentNegotiatingViewResolver
and BeanNameViewResolver
beans.Converter
, GenericConverter
, and Formatter
beans.Converter,GenericConverter,Formatter
HttpMessageConverters
(covered later in this document).HttpMessageConverters
(后来我们配合内容协商理解原理)MessageCodesResolver
(covered later in this document).MessageCodesResolver
(国际化用)index.html
support.Favicon
support (covered later in this document).Favicon
ConfigurableWebBindingInitializer
bean (covered later in this document).ConfigurableWebBindingInitializer
,(DataBinder负责将请求数据绑定到JavaBean上)只要静态资源放在类路径下: called /static
(or /public
or /resources
or /META-INF/resources
访问 : 当前项目根路径/ + 静态资源名
原理: 静态映射/**。
请求进来,先去找Controller看能不能处理。不能处理的所有请求又都交给静态资源处理器。静态资源也找不到则响应404页面
默认无前缀
Favicon
favicon.ico 放在静态资源目录下即可。
所有的请求映射都在HandlerMapping中。
@PathVariable、@RequestHeader、@ModelAttribute、@RequestParam、@MatrixVariable、@CookieValue、@RequestBody
WebRequest、ServletRequest、MultipartRequest、 HttpSession、javax.servlet.http.PushBuilder、Principal、InputStream、Reader、HttpMethod、Locale、TimeZone、ZoneId
Map、Model(map、model里面的数据会被放在request的请求域 request.setAttribute)、Errors/BindingResult、RedirectAttributes( 重定向携带数据)、ServletResponse(response)、SessionStatus、UriComponentsBuilder、ServletUriComponentsBuilder
原文:https://www.cnblogs.com/albertrui/p/15008908.html