网站注册费用,电子商务的网站的建设内容,辽宁好的百度seo公司,银川建设网站以下代码为 spring boot 2.7.15 中自带的 spring 5.3.29 RequestMappingInfo
请求方法相关信息封装#xff0c;对应的信息解析在 RequestMappingHandlerMapping 的 createRequestMappingInfo() 中实现。 对于 RequestMapping 赋值的相关信息进行解析
protected RequestMappi…
以下代码为 spring boot 2.7.15 中自带的 spring 5.3.29 RequestMappingInfo
请求方法相关信息封装对应的信息解析在 RequestMappingHandlerMapping 的 createRequestMappingInfo() 中实现。 对于 RequestMapping 赋值的相关信息进行解析
protected RequestMappingInfo createRequestMappingInfo(RequestMapping requestMapping, Nullable RequestCondition? customCondition) {RequestMappingInfo.Builder builder RequestMappingInfo.paths(resolveEmbeddedValuesInPatterns(requestMapping.path())).methods(requestMapping.method()).params(requestMapping.params()).headers(requestMapping.headers()).consumes(requestMapping.consumes()).produces(requestMapping.produces()).mappingName(requestMapping.name());if (customCondition ! null) {builder.customCondition(customCondition);}return builder.options(this.config).build();} HandlerMapping
实现类为 RequestMappingHandlerMapping 保存了请求路径与 RequestMappingInfo 的关系最终在 AbstractHandlerMethodMapping 的内部类 MappingRegistry 中保存。 HandlerMapping相关实现类 相关的路径信息在 AbstractHandlerMethodMapping 中实现由于实现了接口 InitializingBean在 spring ioc 容器创建完后进行 bean 初始化时进行路径解析处理最终解析为 RequestMappingInfo 对象保存到 AbstractHandlerMethodMapping 的内部类 MappingRegistry 中。 HandlerMethod 保存信息如下 bean bean 名称
beanType bean 类型
method bridgeMethod 方法类型 HandlerAdapter
实现类为 RequestMappingHandlerAdapter
最终请求处理类 HandlerExecutionChain
handler 保存了 HandlerMethod 信息
interceptorList HandlerInterceptor 实现类 请求过程通过 HandlerExecutionChain 中的 HandlerMethod 进行流转最终请求在 InvocableHandlerMethod 中通过反射调用对应 controller 的方法。 HandlerMethod继承类