开发工具:
文件大小: 2mb
下载次数: 0
上传时间: 2019-08-10
详细说明:NULL
博文链接:https://zzc1684.iteye.com/blog/2210510private ServletInvocab lerMe thod createRequestMappingMe thod
HandlerMethod hand LerMe thod, WebDataBinderFactory binderFactory) i
ServletInvocab leHand LerMethod reques tMe thod
requestMe thod= new Se rvletInvocableHandlerMethod (handlerMe thod)
requestMe thod setHandlerMe thodArgumentResolvers (this, argumentResolvers):
requestMe thod, setHandlerMe thodRe turn Va lueHandlers (this, returnva lueHandlers)
requestMe thod, setDataBinderFactory (binderFactory):
requestMe thod, setParameterNameDiscoverer(this, parameterNameDiscoverer):
767
return requestMe thod
MethodParameter类
Handlermethod类中的 parameters属性类型,是一个 Methodparameter数组。 MethodParameter是一个封装了方法参数具体信息
的工具类,包括参数的的索引位置,类型,注解,参数名等信息。
Handlermethod在头例化的时候,构造函数中会初始化这个数组,这时只初始化了部分数据,在 HandlerAdapter对请求处理过程
中会完善其他属性,之后交予合适的 Handler methodArgumentResolver接口处理。
以类 DeptController为例:
Controller
Reques mApping(value =/dept?)
public class DeptController
Autowired
private IDept service deptservice;
RequestMapping( /update
Responsebody
public String update (dept dept)
deptService. saveOrUpdate( dept)
return success
(刚初始化时的数据)
newHandlerMethod= forg springfram ework web method HandlerMethade7966 public java. lang String org format. demo controller Dept Controller up date(org format. demo. m odel
E logger= forg. apache commons logging. im. Loggere78903
p bean= fava. lang String] dept Controller
beanFactory=forg springfram ework web context support Xm IWebA pplication Context5823 WebApplicationContext for namespace ' dispat cher-servlet': startup date [Sat May
method= ava lang reflect. Method7949"public jav a lang String org. format. demo controller. Deptcontroller update(org. form at demo model. Dept)"
a bridgedMethod jjava, lan reflect. Methode79497 public java. lang String org. form at demo controller Dept Controller update(org. form at demo model. Dept)"
E param eters= forg springframework core Method Param eter(1J79721
VE[]=org springframework web, method. HandlerMethod SHandlerMethodParametere79861
E thisto=forg springfram eworkweb, method, HandlerMethod7966 public java. Jang. String org form at demo controller. Dept Controller. update(org. form at demo model D
method=(ava. lang reflect. Methode7949) public java. lang String org. format. demo controller De pt Controller update(org format demo model Depty
constructor null
a parameterIndex=0
ull
parameterlype= nul
genericParameterType= null
刚初始化的时候仅有个 metho和 Daramererindex
E parameterAnnotations= null
parameterName Discoverer= null
三 parameterName=null
图 nestingLevel=1
E typelndexesPerLevel=null
( HandlerAdapter处理后的数据)
parameter=forg. springfram ework web method. HandlerMetho d sHandlerMethod Param etere7986]
this$o= org springframework web method. HandlerMethode7966"public java. lang String org. form at demo, controller. DeptController updat e(org. format. de m o model. Dept)
method =ava. lang reflect Method7949 " public java. lang String org. format. demo controller. Dept Controller. update (org form at. demo model. Dept
constructor = null
a9 parameterIndex=0
containing Class= fava. lang. C1ass7026"class org. form at demo controller. Dept Controller
E parameterType= Ava lang. Classe4555"class org form at demo model. Dept"
>E genericParameterType= java. lang Class, class org. form at. demo. m odel Dept"
BE parameterAnnotations = java. lang annotation Annotation[o18350)
parameterNam eDis coverer= forg. springfram ework care Default ParameterNam eDiscoverere8351F
parameterName null
nestingLevel= 1
typeIndexes PerLevel= null
Request Condition接口:
Spring3.1版本之后引入的。是 SpringMVC的映射基础中的请求条件,可以进行 combine, compareTo, getMatchingCondition
操作。这个接口是映射匹配的关键接口,其中 getMatchingCondition方法关乎是否能找到合适的映射。
a public interface RequestConditioni
T combine(T o ther);
58
TgetmatchinGCondition(httpservletrequestrequest
66側
int compareto(t other Httpserv letrEquest request
RequestMappingInfo类
Spring3.1版本之后引入的。是一个封装了各种请求映射条件并实现了 Request Condition接口的类
有各种 Request Condition实现类属性, patterns Condition, methods Condition, params Condition, headers Condition
consumesCondition以及producesCondition这个请求糸件看属性名也了解,分别代表http请求的路伓模式、方法、参数、头部等
信息
public final class RequestMappingInfo imp lements Request Condition hand LerType
(handler instanceof String getApplicationContext(). get Type((String) handler): handLer getcLass ())
130
/ Avoid repeated calls to getMappingForMe thod which would rebui ld RequestMatchingInfo instances
final Map ()
final Class> userType Classutils getUserClass(handlertype)
Set-Method> methods=Hand lerMethodselector, selectMethods (userType, new Me thodFilter()I
Override
blic boole an matches(Method me thod)i
T mapping getMappingForMethod(me thod, userType)i
It (mapping nulL)t
mappingsput(method, mapping):
return true
这个 mappings中key是 Method
141
这里的泛型T是 ReyuestMappinglnfo
valuei RequestMappingInfo
lse I
return false
144
146
})
注册 HandlerMethod
getMappingForMethod是一个抽象方法
for(Method method: methods)[
regis terHand lerMethod (handler, method, mappings. get(method)
具体实现由
类 RequestMappingHandlermapping实现
(系统自动生成,下载前可以参看下载内容)
下载文件列表
相关说明
- 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
- 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度。
- 本站已设置防盗链,请勿用迅雷、QQ旋风等多线程下载软件下载资源,下载后用WinRAR最新版进行解压.
- 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
- 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
- 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.