DispatcherServlet
-
RequestContextUtils
can get WebApplicationContext - HandlerMapping HandlerMapping是把一个URL指定到一个Controller上
- HandlerAdapter HandlerAdapter是促进DispatcherServlet和第三方框架简单集成的系统级接口。除非使用第三方框架,否则该接口及其实现一般就会对开发者隐藏。DispatcherServlet还会串连在ApplicationContext中的多个适配器,并同时根据Ordered接口对它们进行排序。
- HandlerExceptionResolver
- ViewResolver
DispatcherServlet
workflow:
http://www.processon.com/view/link/55557188e4b090bd2cad57cd
Session access may not be thread-safe, in particular in a Servlet environment. Consider setting theRequestMappingHandlerAdapter
's "synchronizeOnSession" flag to "true" if multiple requests are allowed to access a session concurrently.
Supported method return types
The following are the supported return types:
- A
ModelAndView
object, with the model implicitly enriched with command objects and the results of@ModelAttribute
annotated reference data accessor methods. - A
Model
object, with the view name implicitly determined through aRequestToViewNameTranslator
and the model implicitly enriched with command objects and the results of@ModelAttribute
annotated reference data accessor methods. - A
Map
object for exposing a model, with the view name implicitly determined through aRequestToViewNameTranslator
and the model implicitly enriched with command objects and the results of@ModelAttribute
annotated reference data accessor methods. - A
View
object, with the model implicitly determined through command objects and@ModelAttribute
annotated reference data accessor methods. The handler method may also programmatically enrich the model by declaring aModel
argument (see above). - A
String
value that is interpreted as the logical view name, with the model implicitly determined through command objects and@ModelAttribute
annotated reference data accessor methods. The handler method may also programmatically enrich the model by declaring aModel
argument (see above). -
void
if the method handles the response itself (by writing the response content directly, declaring an argument of typeServletResponse
/HttpServletResponse
for that purpose) or if the view name is supposed to be implicitly determined through aRequestToViewNameTranslator
(not declaring a response argument in the handler method signature). - If the method is annotated with
@ResponseBody
, the return type is written to the response HTTP body. The return value will be converted to the declared method argument type usingHttpMessageConverter
s. See the section called “Mapping the response body with the @ResponseBody annotation”. - An
HttpEntity<?>
orResponseEntity<?>
object to provide access to the Servlet response HTTP headers and contents. The entity body will be converted to the response stream usingHttpMessageConverter
s. See the section called “Using HttpEntity”. - An
HttpHeaders
object to return a response with no body. - A
Callable<?>
can be returned when the application wants to produce the return value asynchronously in a thread managed by Spring MVC. - A
DeferredResult<?>
can be returned when the application wants to produce the return value from a thread of its own choosing. - A
ListenableFuture<?>
can be returned when the application wants to produce the return value from a thread of its own choosing. - Any other return type is considered to be a single model attribute to be exposed to the view, using the attribute name specified through
@ModelAttribute
at the method level (or the default attribute name based on the return type class name). The model is implicitly enriched with command objects and the results of@ModelAttribute
annotated reference data accessor methods.
@ModelAttribute
The @ModelAttribute
annotation can be used on methods or on method arguments
An @ModelAttribute
on a method indicates the purpose of that method is to add one or more model attributes. Such methods support the same argument types as@RequestMapping
methods but cannot be mapped directly to requests. Instead @ModelAttribute
methods in a controller are invoked before @RequestMapping
methods, within the same controller.
In the first, the method adds an attribute implicitly by returning it. In the second, the method accepts a Model
and adds any number of model attributes to it. You can choose between the two styles depending on your needs.
Support for the Last-Modified Response Header To Facilitate Content Caching
There are two key elements to note: calling request.checkNotModified(lastModified)
and returning null
. The former sets the response status to 304 before it returns true
. The latter, in combination with the former, causes Spring MVC to do no further processing of the request.
相关推荐
Spring、SpringMVC和Mybatis是Java开发中最常用的三大开源框架,它们的整合使用,通常被称为SSM框架。这个框架组合提供了完整的后端服务解决方案,包括依赖注入(DI)、面向切面编程(AOP)、模型-视图-控制器(MVC...
SpringMVC是Spring框架的一个模块,专为构建Web应用程序提供模型-视图-控制器(MVC)架构。这个“springMVC练手代码”压缩包包含的资源可以帮助初学者或开发者深入了解并实践SpringMVC的基本操作和核心概念。 首先...
SpringMVC是一款强大的Java web开发框架,用于构建高效、可维护的Web应用程序。在这个"SpringMVC demo 完整源码实例下载"中,我们能够深入理解并学习SpringMVC的核心概念和实际应用。 首先,SpringMVC是Spring框架...
【狂神SpringMVC配套课程代码】一共8个模块,大概可以看我的博客,都是自己学配套整理的 欢迎大家作为学习SpringMVC的参考!! 下面附上狂神B站课程网址,和我的博客笔记(共8章) 狂神老师B站课程:...
SpringMVC是一个强大的Java Web开发框架,由Spring社区开发,它是Spring生态系统的重要组成部分,主要用于构建后端服务。SpringMVC以其灵活的配置、高度模块化和优秀的性能深受开发者喜爱。在这个"springmvc实战项目...
### SpringMVC基础知识详解 #### 一、SpringMVC简介 **SpringMVC**是Spring框架中的一个重要组成部分,主要用于Web应用程序的开发。它遵循MVC(Model-View-Controller)设计模式,帮助开发者构建清晰、可维护的Web...
SpringMVC 是一款基于 Java 的轻量级 Web 开发框架,它是 Spring 框架的重要组成部分,主要用于构建 MVC(Model-View-Controller)模式的 Web 应用程序。本教程将深入探讨 SpringMVC 的核心概念、配置以及实际应用。...
SpringMVC和SQLiteJDBC是两个在Java开发中常见的组件,它们分别用于构建Web应用程序和服务端数据存储。这里我们详细探讨这两个技术以及它们如何协同工作。 **SpringMVC** SpringMVC是Spring框架的一个模块,专门...
本教程将详细阐述如何使用四个关键组件——Maven、SpringMVC、MyBatis和Log4j——来搭建一个强大的Web应用框架,旨在提高开发效率并优化项目管理。 **Maven** 是一个流行的项目管理和综合工具,它通过统一的构建...
【SpringMVC】 SpringMVC是Spring框架的一部分,它是一个用于构建Web应用程序的轻量级、模型-视图-控制器(MVC)架构。SpringMVC通过将业务逻辑、控制逻辑和显示逻辑分离,提高了代码的可维护性和可测试性。在...
SpringMVC、Hibernate和Spring是Java开发中三大核心框架,它们各自负责应用程序的不同层面:SpringMVC用于处理HTTP请求和响应,Hibernate则是持久层框架,负责数据库操作,而Spring作为全能容器,提供依赖注入和面向...
SpringMVC和MyBatis是Java Web开发中的两个核心框架,它们在构建高效、模块化的应用程序方面发挥着重要作用。SpringMVC是Spring框架的一部分,主要负责处理HTTP请求和响应,而MyBatis则是一个轻量级的持久层框架,...
**SpringMVC 入门小程序详解** SpringMVC是Spring框架的一个重要模块,它是一个用于构建Web应用程序的轻量级、模型-视图-控制器(MVC)框架。本入门程序旨在帮助初学者理解并掌握SpringMVC的基本概念和工作流程,...
SpringMVC和Mybatis是Java开发中非常流行的两个框架,它们在企业级Web应用开发中起着关键作用。SpringMVC作为Spring框架的一部分,主要负责处理HTTP请求和响应,而Mybatis则是一个轻量级的持久层框架,专注于数据库...
SpringMVC 拦截器项目是一个典型的 Web 应用开发示例,它利用 SpringMVC 框架中的拦截器(Interceptor)机制来实现特定的功能,如权限控制、日志记录、性能统计等。SpringMVC 是 Spring 框架的一部分,专为构建基于 ...
《尚硅谷SpringMVC部分全套教学文档笔记》涵盖了SpringMVC框架的核心概念和技术,通过一系列章节深入浅出地讲解了SpringMVC的各个方面。以下是基于这些文档内容的详细知识点总结: 1. **SpringMVC概述与HelloWorld*...
Java基于Spring+SpringMVC+MyBatis实现的学生信息管理系统源码,SSM+Vue的学生管理系统。 Java基于Spring+SpringMVC+MyBatis实现的学生信息管理系统源码,SSM+Vue的学生管理系统。 Java基于Spring+SpringMVC+...
SpringMVC是Spring框架的一部分,专门用于构建Web应用程序的模型-视图-控制器(MVC)架构。在本文中,我们将深入探讨SpringMVC 5.0版本的关键特性、使用方法以及它如何增强Web开发的效率。 首先,SpringMVC 5.0是...
在本项目中,我们主要探讨的是如何将SpringMVC、MyBatis、PostgreSQL数据库以及Maven构建工具进行有效的整合,以实现一个高效且模块化的Web应用开发环境。以下是关于这些技术及其整合的关键知识点的详细说明: **1....