Spring mvc 启动 和 请求分发
Spring mvc 启动 和 请求分发
启动加载:
abstract class HttpServletBean extends HttpServlet
void init()
initServletBean(); abstract class FrameworkServlet extends HttpServletBean
void initServletBean()
WebApplicationContext initWebApplicationContext()
onRefresh(wac); class DispatcherServlet extends FrameworkServlet
void onRefresh(ApplicationContext context)
void initStrategies(ApplicationContext context) initMultipartResolver(context);
initLocaleResolver(context);
initThemeResolver(context);
initHandlerMappings(context);
initHandlerAdapters(context);
initHandlerExceptionResolvers(context);
initRequestToViewNameTranslator(context);
initViewResolvers(context);
initFlashMapManager(context); 请求分发:
HTTP request-->httpServlet
--->class FrameworkServlet ---->doPost() or doGet() processRequest(HttpServletRequest request, HttpServletResponse response)
doService(request, response); class DispatcherServlet extends FrameworkServlet
void doService(HttpServletRequest request, HttpServletResponse response)
doDispatch(request, response); // Actually invoke the handler.
mv = ha.handle(processedRequest, response, mappedHandler.getHandler()); SimpleControllerHandlerAdapter implements HandlerAdapter ModelAndView handle(HttpServletRequest request, HttpServletResponse response, Object handler)
((Controller) handler).handleRequest(request, response); 用户在使用时,实现了 AbstractController.handleRequestInternal()
或者 重写 Controller handleRequest() ha 使用哪个Adapter ? 一般需要在配置文件中写明
<bean class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping"/>
<bean class="org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter"/> <bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping"/>
<bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter"/> 下面这个文件中会自动加载
/org/springframework/web/servlet/DispatcherServlet.properties org.springframework.web.servlet.HandlerMapping=org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping,\
org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping org.springframework.web.servlet.HandlerAdapter=org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter,\
org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter,\
org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter
Spring mvc 启动 和 请求分发的更多相关文章
- Spring MVC 处理一个请求的流程分析
Spring MVC是Spring系列框架中使用频率最高的部分.不管是Spring Boot还是传统的Spring项目,只要是Web项目都会使用到Spring MVC部分.因此程序员一定要熟练掌握MV ...
- Spring MVC启动过程(1):ContextLoaderListener初始化
此文来自https://my.oschina.net/pkpk1234/blog/61971 (写的特别好)故引来借鉴 Spring MVC启动过程 以Tomcat为例,想在Web容器中使用Spirn ...
- Spring MVC 异步处理请求,提高程序性能
原文:http://blog.csdn.net/he90227/article/details/52262163 什么是异步模式 如何在Spring MVC中使用异步提高性能? 一个普通 Servle ...
- Spring MVC中forward请求转发2种方式(带参数)
Spring MVC中forward请求转发2种方式(带参数) http://www.51gjie.com/javaweb/956.html
- spring mvc 文件下载 get请求解决中文乱码问题
方案简写,自己或有些基础的可以看懂,因为没时间写的那么详细 方案1 spring mvc解决get请求中文乱码问题, 在tamcat中server.xml文件 URIEncoding="UT ...
- Spring MVC的映射请求
一.SpringMVC常用注解 @Controller 声明Action组件 @Service 声明Service组件 @Service("myMovieLister" ...
- Spring MVC启动流程分析
本文是Spring MVC系列博客的第一篇,后续会汇总成贴子. Spring MVC是Spring系列框架中使用频率最高的部分.不管是Spring Boot还是传统的Spring项目,只要是Web项目 ...
- spring mvc 启动过程及源码分析
由于公司开源框架选用的spring+spring mvc + mybatis.使用这些框架,网上都有现成的案例:需要那些配置文件.每种类型的配置文件的节点该如何书写等等.如果只是需要项目能够跑起来,只 ...
- spring mvc多个请求的影响 和使用全局变量
对于那些会以多线程运行的单例类(比如spring mvc中的controller,dao,service): 局部变量不会受多线程影响 成员变量会受到多线程影响 如果方法里有成员变量,只有读操作,不受 ...
随机推荐
- Java 定制工具库 —— Print(import static)
创建自己的工具库以减少或消除重复的程序代码.例如,我们在Print类中,对常常用到的System.out.println()封装调用以减少输入负担.这样,我们在使用该类时,可以用一个更具可读性的 im ...
- 用exp命令按用户导出的DMP文件缺少表,某些表是空表
1.用以下这句查找空表并生成执行命令 select 'alter table '||table_name||' allocate extent;' from user_tables where num ...
- IDEA模板设置
/** * @className: $CLASSNAME$ * @author: liuyachao * @date: $DATE$ $TIME$ */ ================= ...
- 头像文件上传 方法一:from表单 方法二:ajax
方法一:from表单 html 设置form表单,内包含头像预览div,内包含上传文件input 设置iframe用来调用函数传参路径 <!--表单提交成功后不跳转处理页面,而是将处理数据返回给 ...
- (转载) Android开发mac /dev/kvm is not found
Android开发mac /dev/kvm is not found 标签: KVMAndroid开发KVM is not found芒果Android芒果iOS 2016-10-29 16:31 2 ...
- Site Isolation Design Document
This design document covers technical information about how Site Isolation is built. For a general ...
- 1.1 Python for macOS 安装与配置
本文主要讲解在macOS系统下的Python3.7.0的配置与安装问题 并调试好开发环境 目标是编辑成功第一个python程序 下载最新版(3.7.0)Python macOS系统自带python 不 ...
- Git 修改commit message
1.git log --oneline -5 查看最近5次commit的简要信息,输出信息为:简短commitID commit_message,可以根据需要查看最近n次的提交 也可以git log ...
- 常见VPS buy地址
***,也是最适合新手使用的: https://bwh1.net/ (支持支付宝) vultr,以下是我的分享链接: https://www.vultr.com/(支持支付宝) SugarHosts: ...
- JavaScript(14)jQuery(JavaScript 库)
JavaScript 框架(库) JavaScript 高级程序设计(特别是对浏览器差异的复杂处理),通常非常困难也非常耗时.为了应对这些调整,很多的 JavaScript (helper) 库应运而 ...