如何处理将请求的赋值到control的参数中
- 解析出url对应的匹配规则,匹配到对应的参数,将解析出url对应的值放入
- 解析获得参数值,之后通过反射注入对应的方法中
1. 解析出url对应的匹配规则,匹配到对应的参数。
将解析出url对应的值放入request.setAttribute(HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE, decodedUriVariables);
org.springframework.web.servlet.mvc.method.RequestMappingInfoHandlerMapping
protected void handleMatch
Set<String> patterns = info.getPatternsCondition().getPatterns();
if (patterns.isEmpty()) {
bestPattern = lookupPath;
uriVariables = Collections.emptyMap();
decodedUriVariables = Collections.emptyMap();
}
else {
bestPattern = patterns.iterator().next();
uriVariables = getPathMatcher().extractUriTemplateVariables(bestPattern, lookupPath);
decodedUriVariables = getUrlPathHelper().decodePathVariables(request, uriVariables);
}
request.setAttribute(BEST_MATCHING_PATTERN_ATTRIBUTE, bestPattern);
request.setAttribute(HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE, decodedUriVariables);
matchStrings:692, AntPathMatcher$AntPathStringMatcher (org.springframework.util)
matchStrings:414, AntPathMatcher (org.springframework.util)
doMatch:213, AntPathMatcher (org.springframework.util)
extractUriTemplateVariables:491, AntPathMatcher (org.springframework.util)
handleMatch:131, RequestMappingInfoHandlerMapping (org.springframework.web.servlet.mvc.method)
handleMatch:57, RequestMappingInfoHandlerMapping (org.springframework.web.servlet.mvc.method)
lookupHandlerMethod:370, AbstractHandlerMethodMapping (org.springframework.web.servlet.handler)
getHandlerInternal:314, AbstractHandlerMethodMapping (org.springframework.web.servlet.handler)
getHandlerInternal:61, AbstractHandlerMethodMapping (org.springframework.web.servlet.handler)
getHandler:352, AbstractHandlerMapping (org.springframework.web.servlet.handler)
getHandler:1160, DispatcherServlet (org.springframework.web.servlet)
doDispatch:940, DispatcherServlet (org.springframework.web.servlet)
doService:901, DispatcherServlet (org.springframework.web.servlet)
processRequest:970, FrameworkServlet (org.springframework.web.servlet)
doGet:861, FrameworkServlet (org.springframework.web.servlet)
service:635, HttpServlet (javax.servlet.http)
service:846, FrameworkServlet (org.springframework.web.servlet)
service:742, HttpServlet (javax.servlet.http)
internalDoFilter:231, ApplicationFilterChain (org.apache.catalina.core)
doFilter:166, ApplicationFilterChain (org.apache.catalina.core)
doFilter:52, WsFilter (org.apache.tomcat.websocket.server)
internalDoFilter:193, ApplicationFilterChain (org.apache.catalina.core)
doFilter:166, ApplicationFilterChain (org.apache.catalina.core)
doFilter:359, VosDspLogFilter (com.chinanetcenter.wcs.servlet)
internalDoFilter:193, ApplicationFilterChain (org.apache.catalina.core)
doFilter:166, ApplicationFilterChain (org.apache.catalina.core)
invoke:728, ApplicationDispatcher (org.apache.catalina.core)
processRequest:470, ApplicationDispatcher (org.apache.catalina.core)
doForward:395, ApplicationDispatcher (org.apache.catalina.core)
forward:316, ApplicationDispatcher (org.apache.catalina.core)
doRestV2Filter:309, DomainFilter (com.chinanetcenter.wcs.interceptor)
doFilter:121, DomainFilter (com.chinanetcenter.wcs.interceptor)
堆栈:
handleMatch:136, RequestMappingInfoHandlerMapping (org.springframework.web.servlet.mvc.method)
handleMatch:57, RequestMappingInfoHandlerMapping (org.springframework.web.servlet.mvc.method)
lookupHandlerMethod:370, AbstractHandlerMethodMapping (org.springframework.web.servlet.handler)
getHandlerInternal:314, AbstractHandlerMethodMapping (org.springframework.web.servlet.handler)
getHandlerInternal:61, AbstractHandlerMethodMapping (org.springframework.web.servlet.handler)
getHandler:352, AbstractHandlerMapping (org.springframework.web.servlet.handler)
getHandler:1160, DispatcherServlet (org.springframework.web.servlet)
doDispatch:940, DispatcherServlet (org.springframework.web.servlet)
doService:901, DispatcherServlet (org.springframework.web.servlet)
processRequest:970, FrameworkServlet (org.springframework.web.servlet)
doGet:861, FrameworkServlet (org.springframework.web.servlet)
service:635, HttpServlet (javax.servlet.http)
service:846, FrameworkServlet (org.springframework.web.servlet)
service:742, HttpServlet (javax.servlet.http)
internalDoFilter:231, ApplicationFilterChain (org.apache.catalina.core)
doFilter:166, ApplicationFilterChain (org.apache.catalina.core)
doFilter:52, WsFilter (org.apache.tomcat.websocket.server)
internalDoFilter:193, ApplicationFilterChain (org.apache.catalina.core)
doFilter:166, ApplicationFilterChain (org.apache.catalina.core)
doFilter:359, VosDspLogFilter (com.chinanetcenter.wcs.servlet)
internalDoFilter:193, ApplicationFilterChain (org.apache.catalina.core)
doFilter:166, ApplicationFilterChain (org.apache.catalina.core)
invoke:728, ApplicationDispatcher (org.apache.catalina.core)
processRequest:470, ApplicationDispatcher (org.apache.catalina.core)
doForward:395, ApplicationDispatcher (org.apache.catalina.core)
forward:316, ApplicationDispatcher (org.apache.catalina.core)
doRestV2Filter:309, DomainFilter (com.chinanetcenter.wcs.interceptor)
doFilter:121, DomainFilter (com.chinanetcenter.wcs.interceptor)
2.解析获得参数值,之后通过反射注入对应的方法中。
堆栈
org.springframework.web.method.support.HandlerMethodArgumentResolverComposite
public Object resolveArgument
invoke:498, Method (java.lang.reflect)
doInvoke:205, InvocableHandlerMethod (org.springframework.web.method.support)
invokeForRequest:133, InvocableHandlerMethod (org.springframework.web.method.support)
invokeAndHandle:97, ServletInvocableHandlerMethod (org.springframework.web.servlet.mvc.method.annotation)
invokeHandlerMethod:827, RequestMappingHandlerAdapter (org.springframework.web.servlet.mvc.method.annotation)
handleInternal:738, RequestMappingHandlerAdapter (org.springframework.web.servlet.mvc.method.annotation)
handle:85, AbstractHandlerMethodAdapter (org.springframework.web.servlet.mvc.method)
doDispatch:967, DispatcherServlet (org.springframework.web.servlet)
doService:901, DispatcherServlet (org.springframework.web.servlet)
processRequest:970, FrameworkServlet (org.springframework.web.servlet)
doGet:861, FrameworkServlet (org.springframework.web.servlet)
service:635, HttpServlet (javax.servlet.http)
service:846, FrameworkServlet (org.springframework.web.servlet)
service:742, HttpServlet (javax.servlet.http)
internalDoFilter:231, ApplicationFilterChain (org.apache.catalina.core)
doFilter:166, ApplicationFilterChain (org.apache.catalina.core)
doFilter:52, WsFilter (org.apache.tomcat.websocket.server)
internalDoFilter:193, ApplicationFilterChain (org.apache.catalina.core)
doFilter:166, ApplicationFilterChain (org.apache.catalina.core)
doFilter:359, VosDspLogFilter (com.chinanetcenter.wcs.servlet)
internalDoFilter:193, ApplicationFilterChain (org.apache.catalina.core)
doFilter:166, ApplicationFilterChain (org.apache.catalina.core)
invoke:728, ApplicationDispatcher (org.apache.catalina.core)
processRequest:470, ApplicationDispatcher (org.apache.catalina.core)
doForward:395, ApplicationDispatcher (org.apache.catalina.core)
forward:316, ApplicationDispatcher (org.apache.catalina.core)
doRestV2Filter:309, DomainFilter (com.chinanetcenter.wcs.interceptor)