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.
相关推荐
Java基于Spring+SpringMVC+MyBatis实现的学生信息管理系统源码,SSM+Vue的学生管理系统。 Java基于Spring+SpringMVC+MyBatis实现的学生信息管理系统源码,SSM+Vue的学生管理系统。 Java基于Spring+SpringMVC+...
springmvc
springmvc基础 包含代码+知识点+详细解释 1. 什么是springmvc? 2. springmvc框架原理 前端控制器、处理器映射器、处理器适配器、视图解析器 3. springmvc入门程序 目的:对前端控制器、处理器映射器、处理器...
使用spring+springmvc框架 整合了Mybatis持久层框架 整合Druid用于数据库连接,并使用Druid对业务层监控spring jdbc 整合EhCache,对Mybatis的二级缓存进行管理和对spring进行缓存管理 整合FastJson对指定http类型的...
1、什么是 SpringMvc? 2、Spring MVC 的优点: 3、SpringMVC 工作原理? 4、SpringMVC 流程? 6、SpringMvc 的控制器是不是单例模式,如果是,有什么问题,怎么解决? 7、如果你也用过 struts2.简单介绍下 springMVC ...
完善的Spring+SpringMVC+Mybatis+easyUI后台管理系统(RESTful API+redis).zip 完善的Spring+SpringMVC+Mybatis+easyUI后台管理系统(RESTful API+redis).zip 完善的Spring+SpringMVC+Mybatis+easyUI后台管理系统...
springmvc框架原理(掌握) 前端控制器、处理器映射器、处理器适配器、视图解析器 springmvc入门程序 目的:对前端控制器、处理器映射器、处理器适配器、视图解析器学习 非注解的处理器映射器、处理器适配器 ...
springmvc 笔记
SpringMVC笔记内容:第一天(SpringMVC的概述、SpringMVC与Struts2优势分析、重要组件、运行原理、SpringMVC环境搭建、@RequestMapping注解详解、字符编码过滤器、传参形式(基本数据类型或String、对象类型、对象....
springmvc框架原理(掌握) 前端控制器、处理器映射器、处理器适配器、视图解析器 springmvc入门程序 目的:对前端控制器、处理器映射器、处理器适配器、视图解析器学习 非注解的处理器映射器、处理器适配器 ...
基于springmvc实现分页查询基于springmvc实现分页查询
这是一个简单的springmvc连接数据库的,在xml文件中配置数据库连接,适合初学springmvc,简单易懂
SpringMVC笔记.pdf
springmvc上传文件controller,vue
springMvc整合hibernate Demo
springmvc带进度条上传源码
springMVC集成lucene完整代码
springMVC练手代码,供参考,里面有框架的搭建,以及部分包,可以用于学习
springmvc对json支持
springmvc是常用的一种框架,学习springmvc非常重要,故需要良好教程资料