日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 前端技术 > HTML >内容正文

HTML

管理springmvc组件——前端控制器、控制器映射器和适配器、视图解析器、文件上传的、拦截器||消息转化

發(fā)布時(shí)間:2025/4/16 HTML 23 豆豆
生活随笔 收集整理的這篇文章主要介紹了 管理springmvc组件——前端控制器、控制器映射器和适配器、视图解析器、文件上传的、拦截器||消息转化 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

管理springmvc組件

概述

在使用springmvc時(shí)要配置哪些東西

  • 前端控制器

  • 控制器映射器和適配器

  • 映射器 ?Map<Set<String>,Object>
  • Set<String> 存放資源地 ??
  • @RequestMapper(value={“helle2”,”hello2”})
  • Object ???存放方法對象和方法所有的對象的對象
  • 執(zhí)行方法 method.invoke(obj,args) ??Method
  • 適配器 ?
  • @Controller
  • 實(shí)現(xiàn)Controller接口
  • 實(shí)現(xiàn)HttpRequestHandler的接口
  • 視圖解析器

    InternalResourceViewResolver
  • 文件上傳的

  • 攔截器



  • 前端控制器的自動(dòng)管理

    找到??WebMvcAutoConfiguration

    找到??DispatcherServletAutoConfiguration

    創(chuàng)建

    注冊



    控制器的自動(dòng)管理[就是自定義的controller]

    自動(dòng)掃描

    |--默認(rèn)掃描啟動(dòng)類所有的包及其子包;

    如果不在啟動(dòng)類所有的包及其子包下面?

    要使用 @CompomentScan(basePackage={“com.sxt.controller”,”com.bjsxt.controller”})



    視圖解析器的自動(dòng)管理

    找到??WebMvcAutoConfiguration

    @Bean @ConditionalOnMissingBean public InternalResourceViewResolver defaultViewResolver() {InternalResourceViewResolver resolver = new InternalResourceViewResolver();resolver.setPrefix(this.mvcProperties.getView().getPrefix());resolver.setSuffix(this.mvcProperties.getView().getSuffix());return resolver; }@Bean @ConditionalOnBean(View.class) @ConditionalOnMissingBean public BeanNameViewResolver beanNameViewResolver() {BeanNameViewResolver resolver = new BeanNameViewResolver();resolver.setOrder(Ordered.LOWEST_PRECEDENCE - 10);return resolver; }@Bean @ConditionalOnBean(ViewResolver.class) @ConditionalOnMissingBean(name = "viewResolver", value = ContentNegotiatingViewResolver.class) public ContentNegotiatingViewResolver viewResolver(BeanFactory beanFactory) {ContentNegotiatingViewResolver resolver = new ContentNegotiatingViewResolver();resolver.setContentNegotiationManager(beanFactory.getBean(ContentNegotiationManager.class));// ContentNegotiatingViewResolver uses all the other view resolvers to locate// a view so it should have a high precedenceresolver.setOrder(Ordered.HIGHEST_PRECEDENCE);return resolver; }

    進(jìn)入ContentNegotiatingViewResolver

    總結(jié)

    ContentNegotiatingViewResolver?是一個(gè)視圖解析器的收集器

    只要IOC容器里面有實(shí)現(xiàn)有ViewResolver接口的對象都會(huì)被收集起來? ? 如ThymeleafViewResolver



    文件上傳和下載的視圖解析器

    找到MultipartAutoConfiguration

    找到MultipartProperties



    靜態(tài)資源的訪問

    classpath:resources/MATE-INF/resources

    classpath:resources/resources

    classpath:resources/static

    classpath:resources/public



    消息轉(zhuǎn)化

    找到??WebMvcAutoConfiguration

    格式化轉(zhuǎn)化



    歡迎頁面的配置

    以前web.xml

    <welcome-file-list>

    </webcome-file-list>


    Springboot默認(rèn)配置是static/index.html

    ?

    進(jìn)入WebMvcAutoConfiguration

    總結(jié)

    以上是生活随笔為你收集整理的管理springmvc组件——前端控制器、控制器映射器和适配器、视图解析器、文件上传的、拦截器||消息转化的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。