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): 局部变量不会受多线程影响 成员变量会受到多线程影响 如果方法里有成员变量,只有读操作,不受 ...
随机推荐
- iOS UI01_UIView
// // AppDelegate.m // UI01_UIView // // Created by dllo on 15/7/29. // Copyright (c) 2015年 zhoz ...
- 哈理工2015暑假训练赛 zoj 2078Phone Cell
Phone CellTime Limit:10000MS Memory Limit:32768KB 64bit IO Format:%lld & %llu SubmitStatus ...
- node12---mongodb
一.传统数据库技术回顾 数据库就是存储数据的,那么存储数据就用txt就行了啊,为什么要有数据库? 理由之1: 数据库有行.列的概念,数据有关系,数据不是散的. 老牌数据库,比如MySQL.SQL Se ...
- sql server执行动态拼接sql(带传参数)和去掉小数点后0的函数
1 exec sp_executesql N'SELECT 2 [Extent2].[Id] AS [Id], 3 [Extent2].[Name] AS [Name], 4 [Extent2].[D ...
- JAVA设计模式之【状态模式】
状态模式 水.固态.气态.液态 账户.正常状态.透支状态.受限状态 状态模式中,用一个状态类来分散冗长的条件语句,让系统有灵活性和可扩展性 状态模式用于解决系统中复杂对象的状态转换以及不同状态下行为的 ...
- linux 终端提示符
默认的当路径一长就难看得出奇. 我的设置: export PS1="|\W$>\[\e[0m\]" 最后效果就是|目录名$> 参考:https://www.cnblog ...
- QT笔记 -- (4) 为QLabel添加鼠标响应方法2
1.实现 bool eventFilter(QObject *target,QEvent *event) 函数内容如下: bool eventFilter(QObject *target,QEvent ...
- 搭建python3环境
将Python2.7通过控制面板卸载,然后从网站下载python的安装包,安装即可. 安装beatifulsoup4库.在命令行下, pip install beautifulsoup4 千万不能在p ...
- oracle数据的启动
打开实例 , 数据库到nomount状态: startup nomount; 参数文件 内存,进程 指定控制文件数据库打开到mount状态: alter datatbase mount; 控制文件 ...
- 并发设计模式之Guarded Suspension模式
- 原文链接: http://www.joyhwong.com/2016/11/19/并发设计模式之guarded-suspension模式/ Guarded Suspension意为保护暂停,其核心 ...