- 浏览: 102441 次
- 性别:
- 来自: 北京
博客专栏
-
自己动手写java 框架
浏览量:28410
最新评论
-
zh_harry:
线上demo已经上线http://www.sparrowzoo ...
高性能轻量级markdown 解析器java 版sparrow-markdown -
zh_harry:
sp42 写道演示地址 本地的? 代码 git clone 下 ...
自己动手写mvc框架SPARROW MVC -
sp42:
非常不错 赞一个
高性能轻量级markdown 解析器java 版sparrow-markdown -
sp42:
演示地址 本地的?
自己动手写mvc框架SPARROW MVC -
sp42:
我的框架也是用原生写,已弃坑。还是 MVVM 的爽,推荐 vu ...
SPARROW-JS 从0开始写 0依赖,原生JS框架
DispatcherServlet extends FrameworkServlet extends HttpServletBean extends HttpServletBean extends HttpServlet
服务方法 请求的第一个方法
Process the actual dispatching to the handler
本次请求实际的请求方法
4个实现类
//AnnotationMethodHandlerAdapter 注解实现类
执行handler 方法
获取反射执行方法所需要的参数
//模型注入
服务方法 请求的第一个方法
/** * Exposes the DispatcherServlet-specific request attributes and delegates to {@link #doDispatch} * for the actual dispatching. */ @Override protected void doService(HttpServletRequest request, HttpServletResponse response) throws Exception { if (logger.isDebugEnabled()) { String requestUri = urlPathHelper.getRequestUri(request); logger.debug("DispatcherServlet with name '" + getServletName() + "' processing " + request.getMethod() + " request for [" + requestUri + "]"); } // Keep a snapshot of the request attributes in case of an include, // to be able to restore the original attributes after the include. Map<String, Object> attributesSnapshot = null; if (WebUtils.isIncludeRequest(request)) { logger.debug("Taking snapshot of request attributes before include"); attributesSnapshot = new HashMap<String, Object>(); Enumeration attrNames = request.getAttributeNames(); while (attrNames.hasMoreElements()) { String attrName = (String) attrNames.nextElement(); if (this.cleanupAfterInclude || attrName.startsWith("org.springframework.web.servlet")) { attributesSnapshot.put(attrName, request.getAttribute(attrName)); } } } // Make framework objects available to handlers and view objects. request.setAttribute(WEB_APPLICATION_CONTEXT_ATTRIBUTE, getWebApplicationContext()); request.setAttribute(LOCALE_RESOLVER_ATTRIBUTE, this.localeResolver); request.setAttribute(THEME_RESOLVER_ATTRIBUTE, this.themeResolver); request.setAttribute(THEME_SOURCE_ATTRIBUTE, getThemeSource()); try { [u][b]doDispatch(request, response);[/b][/u] } finally { // Restore the original attribute snapshot, in case of an include. if (attributesSnapshot != null) { restoreAttributesAfterInclude(request, attributesSnapshot); } } }
Process the actual dispatching to the handler
本次请求实际的请求方法
/** * Process the actual dispatching to the handler. * <p>The handler will be obtained by applying the servlet's HandlerMappings in order. * The HandlerAdapter will be obtained by querying the servlet's installed HandlerAdapters * to find the first that supports the handler class. * <p>All HTTP methods are handled by this method. It's up to HandlerAdapters or handlers * themselves to decide which methods are acceptable. * @param request current HTTP request * @param response current HTTP response * @throws Exception in case of any kind of processing failure */ protected void doDispatch(HttpServletRequest request, HttpServletResponse response) throws Exception { HttpServletRequest processedRequest = request; HandlerExecutionChain mappedHandler = null; int interceptorIndex = -1; try { ModelAndView mv; boolean errorView = false; try { processedRequest = checkMultipart(request); // Determine handler for the current request. mappedHandler = getHandler(processedRequest, false); if (mappedHandler == null || mappedHandler.getHandler() == null) { noHandlerFound(processedRequest, response); return; } // Determine handler adapter for the current request. HandlerAdapter ha = getHandlerAdapter(mappedHandler.getHandler()); // Process last-modified header, if supported by the handler. String method = request.getMethod(); boolean isGet = "GET".equals(method); if (isGet || "HEAD".equals(method)) { long lastModified = ha.getLastModified(request, mappedHandler.getHandler()); if (logger.isDebugEnabled()) { String requestUri = urlPathHelper.getRequestUri(request); logger.debug("Last-Modified value for [" + requestUri + "] is: " + lastModified); } //如果是get请求则判断是否有客户端缓存 if (new ServletWebRequest(request, response).checkNotModified(lastModified) && isGet) { return; } } // Apply preHandle methods of registered interceptors. HandlerInterceptor[] interceptors = mappedHandler.getInterceptors(); if (interceptors != null) { for (int i = 0; i < interceptors.length; i++) { HandlerInterceptor interceptor = interceptors[i]; if (!interceptor.preHandle(processedRequest, response, mappedHandler.getHandler())) { triggerAfterCompletion(mappedHandler, interceptorIndex, processedRequest, response, null); return; } interceptorIndex = i; } } //实际请求方法 // Actually invoke the handler. mv =[b] ha.handle(processedRequest, response, mappedHandler.getHandler());[/b] // Do we need view name translation? if (mv != null && !mv.hasView()) { mv.setViewName(getDefaultViewName(request)); } // Apply postHandle methods of registered interceptors. if (interceptors != null) { for (int i = interceptors.length - 1; i >= 0; i--) { HandlerInterceptor interceptor = interceptors[i]; interceptor.postHandle(processedRequest, response, mappedHandler.getHandler(), mv); } } } catch (ModelAndViewDefiningException ex) { logger.debug("ModelAndViewDefiningException encountered", ex); mv = ex.getModelAndView(); } catch (Exception ex) { Object handler = (mappedHandler != null ? mappedHandler.getHandler() : null); mv = processHandlerException(processedRequest, response, handler, ex); errorView = (mv != null); } // Did the handler return a view to render? if (mv != null && !mv.wasCleared()) { render(mv, processedRequest, response); if (errorView) { WebUtils.clearErrorRequestAttributes(request); } } else { if (logger.isDebugEnabled()) { logger.debug("Null ModelAndView returned to DispatcherServlet with name '" + getServletName() + "': assuming HandlerAdapter completed request handling"); } } // Trigger after-completion for successful outcome. triggerAfterCompletion(mappedHandler, interceptorIndex, processedRequest, response, null); } catch (Exception ex) { // Trigger after-completion for thrown exception. triggerAfterCompletion(mappedHandler, interceptorIndex, processedRequest, response, ex); throw ex; } catch (Error err) { ServletException ex = new NestedServletException("Handler processing failed", err); // Trigger after-completion for thrown exception. triggerAfterCompletion(mappedHandler, interceptorIndex, processedRequest, response, ex); throw ex; } finally { // Clean up any resources used by a multipart request. if (processedRequest != request) { cleanupMultipart(processedRequest); } } }
4个实现类
//AnnotationMethodHandlerAdapter 注解实现类
public ModelAndView handle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { Class<?> clazz = ClassUtils.getUserClass(handler); Boolean annotatedWithSessionAttributes = this.sessionAnnotatedClassesCache.get(clazz); if (annotatedWithSessionAttributes == null) { annotatedWithSessionAttributes = (AnnotationUtils.findAnnotation(clazz, SessionAttributes.class) != null); this.sessionAnnotatedClassesCache.put(clazz, annotatedWithSessionAttributes); } if (annotatedWithSessionAttributes) { // Always prevent caching in case of session attribute management. checkAndPrepare(request, response, this.cacheSecondsForSessionAttributeHandlers, true); // Prepare cached set of session attributes names. } else { // Uses configured default cacheSeconds setting. checkAndPrepare(request, response, true); } // 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) { return invokeHandlerMethod(request, response, handler); } } } [b]return invokeHandlerMethod(request, response, handler);[/b] } protected ModelAndView invokeHandlerMethod(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { //handler方法解析器 ServletHandlerMethodResolver methodResolver = getMethodResolver(handler); //handler方法 Method handlerMethod = methodResolver.resolveHandlerMethod(request); //handler方法的执行器 ServletHandlerMethodInvoker methodInvoker = new ServletHandlerMethodInvoker(methodResolver); ServletWebRequest webRequest = new ServletWebRequest(request, response); //上下文map对象 request 及session中的Attribute ExtendedModelMap implicitModel = new BindingAwareModelMap(); //执行handler方法 Object [b]result [/b]= methodInvoker.invokeHandlerMethod(handlerMethod, handler, webRequest, implicitModel); //将执行结果转化的为modelAndView对象 ModelAndView mav = methodInvoker.getModelAndView(handlerMethod, handler.getClass(), [b]result[/b], implicitModel, webRequest); //将当前上下文的内容更新到modelView对象中 methodInvoker.updateModelAttributes(handler, (mav != null ? mav.getModel() : null), implicitModel, webRequest); return mav; }
执行handler 方法
public final Object invokeHandlerMethod(Method handlerMethod, Object handler, NativeWebRequest webRequest, ExtendedModelMap implicitModel) throws Exception { Method handlerMethodToInvoke = BridgeMethodResolver.findBridgedMethod(handlerMethod); try { boolean debug = logger.isDebugEnabled(); //将ssesion中的内容加入到 implicitModel for (String attrName : this.methodResolver.getActualSessionAttributeNames()) { Object attrValue = this.sessionAttributeStore.retrieveAttribute(webRequest, attrName); if (attrValue != null) { implicitModel.addAttribute(attrName, attrValue); } } /*先执行ModelAttributeMethods暴露表单引用对象为模型数据:放在处理器的一般方法(非功能处理方法)上时,是为表单准备要展示的表单引用对象,如注册时需要选择的所在城市等,而且在执行功能处理方法(@RequestMapping注解的方法)之前,自动添加到模型对象中,用于视图页面展示时使用 /** * Annotation that binds a method parameter or method return value * to a named model attribute, exposed to a web view. Supported * for {@link RequestMapping} annotated handler classes. * * <p>Can be used to expose command objects to a web view, using * specific attribute names, through annotating corresponding * parameters of a {@link RequestMapping} annotated handler method). * * <p>Can also be used to expose reference data to a web view * through annotating accessor methods in a controller class which * is based on {@link RequestMapping} annotated handler methods, * with such accessor methods allowed to have any arguments that * {@link RequestMapping} supports for handler methods, returning * the model attribute value to expose. * * @author Juergen Hoeller * @since 2.5 */ @Target({ElementType.PARAMETER, ElementType.METHOD}) //该注解可以注解在方法或参数上 @Retention(RetentionPolicy.RUNTIME) @Documented public @interface ModelAttribute { /** * The name of the model attribute to bind to. * <p>The default model attribute name is inferred from the declared * attribute type (i.e. the method parameter type or method return type), * based on the non-qualified class name: * e.g. "orderAddress" for class "mypackage.OrderAddress", * or "orderAddressList" for "List<mypackage.OrderAddress>". */ String value() default ""; } */ //该注解在方法上 for (Method attributeMethod : this.methodResolver.getModelAttributeMethods()) { Method attributeMethodToInvoke = BridgeMethodResolver.findBridgedMethod(attributeMethod); Object[] args = [b]resolveHandlerArguments(attributeMethodToInvoke, handler, webRequest, implicitModel);[/b] if (debug) { logger.debug("Invoking model attribute method: " + attributeMethodToInvoke); } String attrName = AnnotationUtils.findAnnotation(attributeMethod, ModelAttribute.class).value(); if (!"".equals(attrName) && implicitModel.containsAttribute(attrName)) { continue; } ReflectionUtils.makeAccessible(attributeMethodToInvoke); Object attrValue = attributeMethodToInvoke.invoke(handler, args); if ("".equals(attrName)) { Class resolvedType = GenericTypeResolver.resolveReturnType(attributeMethodToInvoke, handler.getClass()); attrName = Conventions.getVariableNameForReturnType(attributeMethodToInvoke, resolvedType, attrValue); } if (!implicitModel.containsAttribute(attrName)) { implicitModel.addAttribute(attrName, attrValue); } } Object[] args = resolveHandlerArguments(handlerMethodToInvoke, handler, webRequest, implicitModel); if (debug) { logger.debug("Invoking request handler method: " + handlerMethodToInvoke); } ReflectionUtils.makeAccessible(handlerMethodToInvoke); //执行请求方法 return handlerMethodToInvoke.invoke(handler, args); } catch (IllegalStateException ex) { // Internal assertion failed (e.g. invalid signature): // throw exception with full handler method context... throw new HandlerMethodInvocationException(handlerMethodToInvoke, ex); } catch (InvocationTargetException ex) { // User-defined @ModelAttribute/@InitBinder/@RequestMapping method threw an exception... ReflectionUtils.rethrowException(ex.getTargetException()); return null; } }
获取反射执行方法所需要的参数
private Object[] resolveHandlerArguments(Method handlerMethod, Object handler, NativeWebRequest webRequest, ExtendedModelMap implicitModel) throws Exception { Class[] paramTypes = handlerMethod.getParameterTypes(); Object[] args = new Object[paramTypes.length]; for (int i = 0; i < args.length; i++) { MethodParameter methodParam = new MethodParameter(handlerMethod, i); methodParam.initParameterNameDiscovery(this.parameterNameDiscoverer); GenericTypeResolver.resolveParameterType(methodParam, handler.getClass()); String paramName = null; String headerName = null; boolean requestBodyFound = false; String cookieName = null; String pathVarName = null; String attrName = null; boolean required = false; String defaultValue = null; boolean validate = false; int annotationsFound = 0; Annotation[] paramAnns = methodParam.getParameterAnnotations(); for (Annotation paramAnn : paramAnns) { if (RequestParam.class.isInstance(paramAnn)) { RequestParam requestParam = (RequestParam) paramAnn; paramName = requestParam.value(); required = requestParam.required(); defaultValue = parseDefaultValueAttribute(requestParam.defaultValue()); annotationsFound++; } else if (RequestHeader.class.isInstance(paramAnn)) { RequestHeader requestHeader = (RequestHeader) paramAnn; headerName = requestHeader.value(); required = requestHeader.required(); defaultValue = parseDefaultValueAttribute(requestHeader.defaultValue()); annotationsFound++; } else if (RequestBody.class.isInstance(paramAnn)) { requestBodyFound = true; annotationsFound++; } else if (CookieValue.class.isInstance(paramAnn)) { CookieValue cookieValue = (CookieValue) paramAnn; cookieName = cookieValue.value(); required = cookieValue.required(); defaultValue = parseDefaultValueAttribute(cookieValue.defaultValue()); annotationsFound++; } else if (PathVariable.class.isInstance(paramAnn)) { PathVariable pathVar = (PathVariable) paramAnn; pathVarName = pathVar.value(); annotationsFound++; } //这里是参数类型 该注解在参数上 else if (ModelAttribute.class.isInstance(paramAnn)) { ModelAttribute attr = (ModelAttribute) paramAnn; attrName = attr.value(); annotationsFound++; } else if (Value.class.isInstance(paramAnn)) { defaultValue = ((Value) paramAnn).value(); } else if ("Valid".equals(paramAnn.annotationType().getSimpleName())) { validate = true; } } if (annotationsFound > 1) { throw new IllegalStateException("Handler parameter annotations are exclusive choices - " + "do not specify more than one such annotation on the same parameter: " + handlerMethod); } if (annotationsFound == 0) { Object argValue = resolveCommonArgument(methodParam, webRequest); if (argValue != WebArgumentResolver.UNRESOLVED) { args[i] = argValue; } else if (defaultValue != null) { args[i] = resolveDefaultValue(defaultValue); } else { Class paramType = methodParam.getParameterType(); if (Model.class.isAssignableFrom(paramType) || Map.class.isAssignableFrom(paramType)) { args[i] = implicitModel; } else if (SessionStatus.class.isAssignableFrom(paramType)) { args[i] = this.sessionStatus; } else if (HttpEntity.class.isAssignableFrom(paramType)) { args[i] = resolveHttpEntityRequest(methodParam, webRequest); } else if (Errors.class.isAssignableFrom(paramType)) { throw new IllegalStateException("Errors/BindingResult argument declared " + "without preceding model attribute. Check your handler method signature!"); } else if (BeanUtils.isSimpleProperty(paramType)) { paramName = ""; } else { attrName = ""; } } } if (paramName != null) { args[i] = resolveRequestParam(paramName, required, defaultValue, methodParam, webRequest, handler); } else if (headerName != null) { args[i] = resolveRequestHeader(headerName, required, defaultValue, methodParam, webRequest, handler); } else if (requestBodyFound) { args[i] = resolveRequestBody(methodParam, webRequest, handler); } else if (cookieName != null) { args[i] = resolveCookieValue(cookieName, required, defaultValue, methodParam, webRequest, handler); } else if (pathVarName != null) { args[i] = resolvePathVariable(pathVarName, methodParam, webRequest, handler); } //struts 2的模型驱动 else if (attrName != null) { WebDataBinder binder = resolveModelAttribute(attrName, methodParam, implicitModel, webRequest, handler); boolean assignBindingResult = (args.length > i + 1 && Errors.class.isAssignableFrom(paramTypes[i + 1])); if (binder.getTarget() != null) { doBind(binder, webRequest, validate, !assignBindingResult); } args[i] = binder.getTarget(); if (assignBindingResult) { args[i + 1] = binder.getBindingResult(); i++; } implicitModel.putAll(binder.getBindingResult().getModel()); } } return args; }
//模型注入
private WebDataBinder resolveModelAttribute(String attrName, MethodParameter methodParam, ExtendedModelMap implicitModel, NativeWebRequest webRequest, Object handler) throws Exception { // Bind request parameter onto object... String name = attrName; if ("".equals(name)) { name = Conventions.getVariableNameForParameter(methodParam); } Class<?> paramType = methodParam.getParameterType(); Object bindObject; if (implicitModel.containsKey(name)) { bindObject = implicitModel.get(name); } else if (this.methodResolver.isSessionAttribute(name, paramType)) { bindObject = this.sessionAttributeStore.retrieveAttribute(webRequest, name); if (bindObject == null) { raiseSessionRequiredException("Session attribute '" + name + "' required - not found in session"); } } else { bindObject = BeanUtils.instantiateClass(paramType); } WebDataBinder binder = createBinder(webRequest, bindObject, name); initBinder(handler, name, binder, webRequest); return binder; } protected void initBinder(Object handler, String attrName, WebDataBinder binder, NativeWebRequest webRequest) throws Exception { if (this.bindingInitializer != null) { this.bindingInitializer.initBinder(binder, webRequest); } if (handler != null) { Set<Method> initBinderMethods = this.methodResolver.getInitBinderMethods(); if (!initBinderMethods.isEmpty()) { boolean debug = logger.isDebugEnabled(); for (Method initBinderMethod : initBinderMethods) { Method methodToInvoke = BridgeMethodResolver.findBridgedMethod(initBinderMethod); String[] targetNames = AnnotationUtils.findAnnotation(initBinderMethod, InitBinder.class).value(); if (targetNames.length == 0 || Arrays.asList(targetNames).contains(attrName)) { Object[] initBinderArgs = resolveInitBinderArguments(handler, methodToInvoke, binder, webRequest); if (debug) { logger.debug("Invoking init-binder method: " + methodToInvoke); } ReflectionUtils.makeAccessible(methodToInvoke); Object returnValue = methodToInvoke.invoke(handler, initBinderArgs); if (returnValue != null) { throw new IllegalStateException( "InitBinder methods must not have a return value: " + methodToInvoke); } } } } } }
发表评论
-
零基础小白从0到1的spring cloud alibaba 全家桶项目
2022-10-18 02:15 2551零基础暖心计划课程内容 https://spar ... -
sparrow 支持JDK依赖注入功能
2022-08-02 15:28 2008麻雀虽小,但五脏俱全 sparrow 源自中国俗语 ... -
Sparrow js 框架开源上线
2019-06-29 21:28 1045sparraw 框架js 版开源上线 www.sparr ... -
SPARROW-JS 从0开始写 0依赖,原生JS框架
2018-03-15 19:52 1672SPARROW-JS 前端JS框架变幻莫测,但原生js 接口 ... -
Sparrow算法篇 从日期取交集到思维模式-2
2018-03-09 18:04 1565接上一篇 Sparrow算法篇 从日期取交集到思维模式 ... -
高性能轻量级markdown 解析器java 版sparrow-markdown
2018-02-24 17:17 4337动机 markdown 已成为网络博客最主要的排版格式。 ... -
Sparrow 算法篇 由日期取交集到思维模式
2018-02-06 23:46 1772日期交集 早在13年左右的时侯,做过一个系统,功能很简单 ... -
自己动手写mvc框架SPARROW MVC
2018-02-01 22:31 1595SPARROW-MVC SPARROW-MVC 是SPA ... -
REDIS客户端封装实践2
2018-01-30 13:32 1126接上一篇 [REDIS客户端封装意淫](https:// ... -
SPARROW 框架redis客户端封装实践
2018-01-25 21:41 1156redis 本身有客户端,先抛出来一个问题?为什么要对red ... -
SPARROW架构介绍
2018-01-24 22:02 1312sparrow 框架设计最大化解耦,理论上业务层只依赖SPA ... -
Sparrow 框架设计哲学
2018-01-24 13:21 1274sparrow 框架 麻雀虽小,但五脏俱全 为什么要写这 ... -
tomcat 日志那点事
2017-07-15 14:06 813tomcat 启动时使用的是java.util.logger ... -
疯子在思考之-异常与return 的差别
2013-10-14 14:46 1439程序异常会中断程序执行,所有所有的异常都需要捕获,否则会 ... -
MANIFEST.MF 文件内容完全详解
2013-09-02 14:49 1326打开Java的JAR文件我们经常可以看到文件中包含着一个ME ... -
疯子奉献-一个符号惹的祸
2013-08-30 14:14 1778程序员是严谨的,但是再严谨也容易出问题,这就叫做bug。 我 ... -
疯子在思考之-从日志想到的软件架构
2013-08-28 18:57 1948谈到架构是一个很泛的话题 这里我们讨论一下兼容性与扩展性 ... -
疯子在思考之java 线程的那点事儿
2013-08-14 15:13 3299很长时间没写博客了,最近事情比较多 之前在文章中提到过tomc ... -
linux 自动重启tomcat 脚本
2013-08-12 17:59 3012Tomcat作为开源的服务器 ... -
tomcat 优化及错误All threads (10) are currently busy, waiting. Increase maxThreads错误
2013-08-12 17:42 15961. 如何加大tomcat连接数 在tomcat配置文件se ...
相关推荐
对Spring MVC源码的深入剖析不仅有助于开发者更好地理解框架的工作机制,而且可以为开发定制化组件、性能优化及故障排查等提供坚实的知识基础。通过学习和实践,开发者可以更有效地利用Spring MVC框架来构建高性能的...
Spring MVC源码的深入理解有助于开发者更好地掌握框架的工作原理,优化代码性能,甚至为自定义扩展提供基础。 压缩包内的文件"www.pudn.com.txt"可能是一个链接或说明文档,指向更多关于该主题的资源,例如在pudn....
总的来说,"Mastering Spring MVC 4(2015.09)源码"提供了深入学习Spring MVC的机会,你可以通过阅读和分析源码来了解如何配置DispatcherServlet、怎样编写控制器、如何进行数据绑定与验证,以及如何利用拦截器等特性...
【Spring5MVC源码分析】 Spring MVC 是一个基于Java的、用于构建Web应用程序的、高度可插拔的MVC框架,它是Spring Framework的重要组成部分。Spring MVC的核心目标是简化前端控制器的开发,使得开发者可以专注于...
10. **源码解析**:深入理解Spring MVC源码有助于你更好地优化应用性能和解决问题。例如,了解DispatcherServlet如何分发请求,HandlerMapping如何匹配控制器,以及ModelAndView是如何工作的。 这个项目中的源码...
- 配置Spring MVC:在Spring的配置文件中,我们需要定义DispatcherServlet、视图解析器和处理器映射器等。 - 集成MyBatis:引入MyBatis的依赖,配置SqlSessionFactoryBean,创建MapperScannerConfigurer扫描Mapper...
在本源码分析中,我们将探讨Spring MVC的工作原理、主要组件及其交互方式。 1. **DispatcherServlet**: 作为Spring MVC的前端控制器,DispatcherServlet是所有请求的入口点。它负责拦截请求,根据请求信息(如URL、...
《互联网轻量级SSM框架解密:Spring、Spring MVC、MyBatis源码深度剖析》Spring 源码剖析篇基于Spring 4.3.2 版本,剖析了Spring 上下文、Spring AOP 和Spring 事务的实现,并通过实例展示了框架陷阱的隐蔽性及学习...
而`spring-framework-2.5.6-with-docs.zip`可能包含了Spring 2.5.6的源码和文档,帮助开发者了解Spring MVC的内部实现和最佳实践。 总之,这个压缩包提供了开发基于Spring MVC和Hibernate的Java Web应用所需要的...
Spring源码深度解析第二版 Spring是一款广泛应用于Java企业级应用程序的开源框架,旨在简化Java应用程序的开发和部署。Spring框架的核心主要包括了IoC容器、AOP、MVC框架等模块。 第1章 Spring整体架构和环境搭建 ...
这个"Spring MVC 基础实例源码01"的资源很可能是为了帮助初学者理解Spring MVC的核心概念和基本用法。下面我们将详细探讨Spring MVC的一些关键知识点。 1. **MVC模式**:MVC(Model-View-Controller)是一种设计...
7. **多视图解析器**:Spring MVC支持多种视图解析器,如JSP、FreeMarker、Thymeleaf等,可以根据项目需求灵活选择。 8. **模板引擎集成**:例如,与Thymeleaf的集成使得开发者能编写声明式逻辑的模板,提高了视...
本书由浅入深地介绍了当今流行的Java Web框架Spring MVC的方方面面,从基础的环境搭建到微服务设计与架构,再到持久化、REST API构建、认证与测试……涵盖了Spring MVC诸多重要且常用的特性。值得一提的是,本书针对...
《精通Spring MVC 4》源码是一份宝贵的资源,它为开发者提供了深入理解Spring MVC这一流行Web框架的机会。Spring MVC是Spring框架的一部分,专门用于构建高效、可维护的Web应用程序。通过阅读和研究这些源码,我们...
在这个项目源码中,我们可以深入理解 Spring MVC 的工作原理以及如何在实际应用中使用它。 1. **Spring MVC 架构**: Spring MVC 包含了 DispatcherServlet、HandlerMapping、HandlerAdapter、ModelAndView、...
其中定义了Bean的配置,包括DataSource、JdbcTemplate或JpaTemplate等,以及Spring MVC的配置文件(如`servlet-context.xml`),定义了DispatcherServlet的设置和视图解析器。 2. **模型(Model)**:包含了业务...
7. **视图解析**:Spring MVC 4.0支持多种视图技术,如JSP、FreeMarker、Thymeleaf等,视图解析器可以根据配置自动选择合适的视图技术。 8. **异步处理**:Spring MVC 4.0引入了异步请求处理,通过@...
这本书“看透Spring MVC源代码分析与实践”显然是为了帮助开发者深入理解Spring MVC的工作原理,并通过源码分析提升实战技能。在本文中,我们将探讨Spring MVC的关键概念、设计模式以及源码中的重要组成部分。 1. *...
**Spring MVC 4.2.4.RELEASE 中文文档** Spring MVC是Spring框架的一个核心组件,专注于构建Web应用程序。它提供了模型-视图-控制器(MVC)架构,帮助开发者组织和分离应用的业务逻辑、数据处理以及用户界面。...