how spring resolves a request
quoted from answer at http://stackoverflow.com/questions/14015642/how-does-the-dispatcherservlet-resolver-and-controllers-interact
When sending a request to your application the following happens:
- The request arrives at your server (e.g. Tomcat). Depending on the context path in the url the server decides to which application the request belongs.
- Depending on the url and the servlet mapping in the web.xml file of your application the server knows which servlet should handle the request.
- The request is passed to the servlet filter chain which can modify or reject requests
- The servlet takes control over the request. In case of your Spring application the spring Dispatcherservlet receives the request. Now Spring kicks in
- The request is processed by mvc intercepters
preHandlemethods - The request is mapped to a controller based on the url. The corresponding controller method will be called.
- Your controller is processing the request. Many different responses can be returned in controllers (jsp, pdf, json, redirects, etc.). For now i assume you want to render a simple jsp view. Result of the controller are two things: a model and a view. The model is a map that contains the data you want to access later in your view. The view at this stage is most of the time a simple string containing a view name.
- Registered springs mvc interceptors can kick in again using the
postHandlemethod (e.g. for modifying the model) - The 'view' result of your controller is resolved to a real View using a
ViewResolver. Depending on the ViewResolver the result can be jsp page, a tiles view, a thymeleaf templateor many other 'Views'. In your case theViewResolverresolves a view name (e.g. 'myPage') to a jsp file (e.g./WEB-INF/jsp/myPage.jsp) - The view is rendered using the model data returned by your controller
- The response with the rendered view will be passed to mvc interceptors again (
afterCompletionmethod) - The response leaves the dispatcher servlet. Here ends spring land.
- The response passes servlet filters again
- The response is send back to client
how spring resolves a request的更多相关文章
- Spring中获取request的几种方法,及其线程安全性分析
前言 本文将介绍在Spring MVC开发的web系统中,获取request对象的几种方法,并讨论其线程安全性. 原创不易,如果觉得文章对你有帮助,欢迎点赞.评论.文章有疏漏之处,欢迎批评指正. 欢迎 ...
- [No000016E]Spring 中获取 request 的几种方法,及其线程安全性分析
前言 本文将介绍在Spring MVC开发的web系统中,获取request对象的几种方法,并讨论其线程安全性. 原创不易,如果觉得文章对你有帮助,欢迎点赞.评论.文章有疏漏之处,欢迎批评指正. 欢迎 ...
- Spring中获取request的几种方法,及其线程安全性分析(山东数漫江湖)
前言 本文将介绍在Spring MVC开发的web系统中,获取request对象的几种方法,并讨论其线程安全性. 原创不易,如果觉得文章对你有帮助,欢迎点赞.评论.文章有疏漏之处,欢迎批评指正. 欢迎 ...
- spring 异步处理request
转自:http://blog.csdn.net/u012410733/article/details/52124333Spring MVC 3.2开始引入Servlet 3中的基于异步的处理reque ...
- [Java][web]利用Spring随时随地获得Request和Session
利用Spring随时随地获得Request和Session 一.准备工作: 在web.xml中加入 <listener> <listener-class> org.spring ...
- spring 组件@Scope(request,session)示例
上回说到, spring组件的注解Scope大约有singleton.prototype.request.session.global session 这么几种常用的场景.这里需要特别说明一下,根据源 ...
- spring boot The request was rejected because the URL was not normalized
升级spring boot 1.5.10.RELEASE 版本后,突然发现之前能Nginx代理能请求的地址抛如下异常: org.springframework.security.web.firewal ...
- 如何在spring中获取request对象
1.通过注解获取(很简单,推荐): public class Hello {@Autowired HttpServletRequest request; //这里可以获取到request} 2.在w ...
- spring aop 获取request、response对象
在网上看到有不少人说如下方式获取: 1.在web.xml中添加监听 <listener> <listener-class> org. ...
随机推荐
- poj3592 强连通+记忆化搜索
题意:有一片 n*m 的矿地,每一格有矿.或这传送门.或者挡路岩石.除了岩石不能走以外,其他的格子都能够向右或向下走,走到一个非岩石的格子.对于每一个矿点,经过它就能得到它的所有矿石,而对于每一个传送 ...
- Spring异常累计(1)Spring注解与扫描,NoUniqueBeanDefinitionException
spring中可以使用注解机制,代替传统的在xml中配置一个bean. 如 <pre name="code" class="java">@Compo ...
- angular+bootstrap+MVC 之三,分页控件初级版
今天实现一个分页控件,效果如下: 1.HTML: <!doctype html> <!--suppress ALL --> <html ng-app="appT ...
- ruby中http请求方法整理
#POST请求 请求包是json包 返回body并转换成json对象def post_json *args uri = URI.parse args[0] req = Net::HTTP::Post. ...
- bzoj2006 noi2010 超级钢琴 主席树 + 优先队列
Time Limit: 20 Sec Memory Limit: 552 MBSubmit: 2435 Solved: 1195 Description 小 Z是一个小有名气的钢琴家,最近C博士送 ...
- 用Visual Studio调试Windows和驱动程序
由于本人能力有限,翻译不足之处敬请谅解,欢迎批评指正:sunylat@163.com Visual Studio版本:Visual Studio 2015企业版,中文环境. MSDN原文:https: ...
- .netGDI+(转)
架上图片了你就可以在画板上涂改了啊我要写多几个字上去 string str = "Baidu"; //写什么字? Font font = Font("宋体",3 ...
- delphi 调用c#dll
public interface iProduct { string Buy(); } [ClassInterface(ClassInterfaceType.None)] public class P ...
- ubuntu14.04网络设置
修改ip: /etc/network/interfaces
- JSTL+MyEclipse8.5+Tomcat配置
使用JSTL的时候需要配置,即导入stdandard.jar和jstl.jar包,并在web.xml下对jstl进行配置.下面是使用步骤: 1. 解压jakarta-taglibs-standard- ...