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
preHandle
methods - 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
postHandle
method (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 theViewResolver
resolves 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 (
afterCompletion
method) - 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. ...
随机推荐
- 解析HTTP协议六种请求方法,get,head,put,delete,post有什么区别
GET: 请求指定的页面信息,并返回实体主体.HEAD: 只请求页面的首部.POST: 请求服务器接受所指定的文档作为对所标识的URI的新的从属实体.PUT: 从客户端向服务器传送的数据取代指定的文档 ...
- 递归输出文件夹下的所有文件的名称(转自 MSDN)
问题:如何输出给定文件夹目录下面的所有文件的名称? C#代码: using System; using System.IO; namespace MyTest { public class Progr ...
- 用minidwep-gtk研究wifi
全图,不解释
- Openstack Neutron L2 Population
Why do we need it, whatever it is? VM unicast, multicast and broadcast traffic flow is detailed in m ...
- Apache + PHP 环境搭建
环境: Win7 64位 php-5.6.19-Win32-VC11-x64 httpd-2.4.18-win64-VC11 下载地址: php: http://windows.php.net/do ...
- linux 下 用户与用户组
1,增加一个test组:groupadd test 2,将test组重命名test2:groupmod -n test2 test 3,删除test2组:groupdel test2 4,查看当前登录 ...
- JAVA设计模式之桥梁模式
在阎宏博士的<JAVA与模式>一书中开头是这样描述桥梁(Bridge)模式的: 桥梁模式是对象的结构模式.又称为柄体(Handle and Body)模式或接口(Interface)模式. ...
- [EventBus源码解析] EventBus.register 方法详述
前情概要 在上一篇中,介绍了EventBus的基本使用方法,以及一部分进阶技巧.本篇及以后的几篇blog将会集中解析EventBus.java,看看作者是如何优雅地实现这个看似简单的事件分发/接收机制 ...
- 剑指Offer:面试题24——二叉搜索树的后序遍历序列(java实现)
问题描述: 输入一个整数数组,判断该数组是不是某二叉搜索树的后序遍历的结果.如果是则返回true,否则返回false.假设输入的数组的任意两个数字都互不相同. 思路: 1.首先后序遍历的结果是[(左子 ...
- js显示当前时间
闲着没事在闪存里看到有人需要js显示当前时间,就一时兴起写了个. 输出格式:“2013年12月18日 星期三 上午9:05:00 ”. <script type="text/javas ...