我确信http请求只发送一次。但是当交易函数RequestMappingHandlerAdapter.handleInternal
时,显然会调用两次invokeHandlerMethod
。代码:
@Override
protected ModelAndView handleInternal(HttpServletRequest request,
HttpServletResponse response, HandlerMethod handlerMethod) throws Exception {
ModelAndView mav = null;
checkRequest(request);
// Execute invokeHandlerMethod in synchronized block if required.
if (this.synchronizeOnSession) {
HttpSession session = request.getSession(false);
if (session != null) {
Object mutex = WebUtils.getSessionMutex(session);
synchronized (mutex) {
mav = invokeHandlerMethod(request, response, handlerMethod);
}
}
}
mav = invokeHandlerMethod(request, response, handlerMethod);
if (getSessionAttributesHandler(handlerMethod).hasSessionAttributes()) {
applyCacheSeconds(response, this.cacheSecondsForSessionAttributeHandlers);
}
else {
prepareResponse(response);
}
return mav;
}
我无法理解为什么在这里调用两次invokeHandlerMethod(request, response, handlerMethod)
。mav
必须是第二次调用的结果,对吧?
答案 0 :(得分:0)