springmvc register过程
福建SEO:首先在AbstractHandlerMethodMapping中,在afterPropertiesSet这个钩子函数中,先初始化handlerMethods。
在detectHandlerMethods中,获取如下map
// key值为method value为 RequestMappingInfo 这个类标明了该方法的条件 包括url以及http方法等等信息
Map<Method, T> methods = MethodIntrospector.selectMethods(userType,
(MethodIntrospector.MetadataLookup<T>) method -> {
try {
return getMappingForMethod(method, userType);
}
catch (Throwable ex) {
throw new IllegalStateException("Invalid mapping on handler class [" +
userType.getName() + "]: " + method, ex);
}
});
注册的过程在方法中进行
// mapping 的信息 handler为该方法的bean的name method为方法
public void register(T mapping, Object handler, Method method) {
// Assert that the handler method is not a suspending one.
if (KotlinDetector.isKotlinType(method.getDeclaringClass()) && KotlinDelegate.isSuspend(method)) {
throw new IllegalStateException("Unsupported suspending handler method detected: " + method);
}
// 先获取写锁
this.readWriteLock.writeLock().lock();
try {
HandlerMethod handlerMethod = createHandlerMethod(handler, method);
validateMethodMapping(handlerMethod, mapping);
this.mappingLookup.put(mapping, handlerMethod); List<String> directUrls = getDirectUrls(mapping);
for (String url : directUrls) {
this.urlLookup.add(url, mapping);
} String name = null;
if (getNamingStrategy() != null) {
name = getNamingStrategy().getName(handlerMethod, mapping);
addMappingName(name, handlerMethod);
} CorsConfiguration corsConfig = initCorsConfiguration(handler, method, mapping);
if (corsConfig != null) {
this.corsLookup.put(handlerMethod, corsConfig);
} this.registry.put(mapping, new MappingRegistration<>(mapping, handlerMethod, directUrls, name));
}
finally {
this.readWriteLock.writeLock().unlock();
}
}
springmvc register过程的更多相关文章
- SpringMVC启动过程详解(li)
通过对SpringMVC启动过程的深入研究,期望掌握Java Web容器启动过程:掌握SpringMVC启动过程:了解SpringMVC的配置文件如何配置,为什么要这样配置:掌握SpringMVC是如 ...
- 深入源码分析SpringMVC执行过程
本文主要讲解 SpringMVC 执行过程,并针对相关源码进行解析. 首先,让我们从 Spring MVC 的四大组件:前端控制器(DispatcherServlet).处理器映射器(HandlerM ...
- springmvc配置过程中遇到的一些问题总结
springmvc配置过程中遇到的一些问题总结 1.配置tomcat过程中的错误: 2.配置web.xml中DispatchServlet报红(配置好已有依赖条件下) 解决的办法: 因为新添加依赖,m ...
- springMvc 启动过程
转载自https://www.jianshu.com/p/dc64d02e49ac 这里给出一个简洁的文字描述版SpringMVC启动过程: tomcat web容器启动时会去读取web.xml这样的 ...
- 浅谈SpringMVC执行过程
通过深入分析Spring源码,我们知道Spring框架包括大致六大模块, 如Web模块,数据库访问技术模块,面向切面模块,基础设施模块,核心容器模块和模块, 其中,在Spring框架的Web模块中,又 ...
- springMVC工作过程
学习springmvc之前先学习一下他的工作过程 如图 1.用户通过客户端向服务器发送请求,请求会被springMVC的前端控制器DispatchServlet所拦截. 2.DispatchServl ...
- SpringMvc执行过程
--Test过程: 1. 先执行各种 Filter 2. HttpServlet.service(ServletRequest req, ServletResponse res) 3. HttpSer ...
- Spring Taco Cloud——Controller的创建(含SpringMVC执行过程&SpringBoot&Spring三者解释及关联)
在记录这次控制器编写前,对于Spring的感觉就是经常提这样代码好简洁,这样好方便,这个是用来干嘛的诸如之类的话. What is Spring ?这是我想问自己的,一直认为是简化代码利于工程的开源框 ...
- springmvc请求处理过程
springmvc请求的处理流程 1)发起some.do 2)tomcat(web.xml-----url-pattern知道*.do的请求给DispatcherServlet) 3)Dispatch ...
随机推荐
- 面试题(6)之 leetcode-001
1. 两数之和 给定一个整数数组 nums 和一个目标值 target,请你在该数组中找出和为目标值的那 两个 整数,并返回他们的数组下标. 你可以假设每种输入只会对应一个答案.但是,你不能重复利用这 ...
- Sequence Models Week 3 Trigger word detection
Trigger Word Detection Welcome to the final programming assignment of this specialization! In this w ...
- redis常用命令--基础
redis默认有个数据库,下标从开始,不支持自定义数据库名字. 使用select index 切换数据库 : select 7 (切换到第八个数据库) dbsize:求当前数据库中键值对的数量. ...
- javacv 设置帧率(续)
前文地址:https://www.cnblogs.com/svenwu/p/9663038.html 前文已经对大多数正常情况可以支持了,但是我最近处理一些公司的视频流,发现一些坑爹的情况 每次给的视 ...
- 使用代理IP访问网络
现在很多领域都需要用到代理IP,用到的领域越来越广,如爬虫.投票.抢购等等. 代理IP免费获取地址:http://www.xicidaili.com/(少部分可以用) 我这个案例使用的上面地址里面的免 ...
- CTF -攻防世界-web新手区
直接f12出来 先用get后加/?a=1 然后火狐装hackbar(老版本)f12 post b=2 搞定 Hackbar:https://github.com/Mr-xn/hackbar2.1.3 ...
- Cracking Digital VLSI Verification Interview 第二章
Computer Architecture 对Cracking Digital VLSI Verification Interview:Interview Success这本书的汉化,最新更新请关注微 ...
- 干货 | DRDS 与TiDB浅析
干货 | DRDS 与TiDB浅析 北京it爷们儿 京东云开发者社区 4月17日 在谈论数据库架构和数据库优化的时候,会常听到"分库分表"."分片".&quo ...
- LeetCode——324. 摆动排序 II
给定一个无序的数组 nums,将它重新排列成 nums[0] < nums[1] > nums[2] < nums[3]... 的顺序. 示例 1: 输入: nums = [1, 5 ...
- HDU-4460 Friend Chains(BFS&权为1所有最短路的最大值)
题目: For a group of people, there is an idea that everyone is equals to or less than 6 steps away fro ...