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. ...
随机推荐
- ssh隧道(端口转发)
本地转发: ssh -Nf -L [bind_address:]port:host:hostport sshServer -Nf 后台运行 -L 本地转发 [bind_address] 绑定本地地址, ...
- SoftEnther VPN 在Window的使用
1.首先下载SoftEnther VPN Client 下载地址 2. 下载后,执行vpngate-client-×××.exe 文件 选择安装一个软件部分: SoftEnther VPN Clien ...
- WinForm中使用XML文件存储用户配置及操作本地Config配置文件
大家都开发winform程序时候会大量用到配置App.config作为保持用户设置的基本信息,比如记住用户名,这样的弊端就是每个人一些个性化的设置每次更新程序的时候会被覆盖. 故将配置文件分两大类: ...
- Shiro 整合SpringMVC 并且实现权限管理
Apache Shiro是Java的一个安全框架.目前,使用Apache Shiro的人越来越多,因为它相当简单,对比Spring Security,可能没有Spring Security做的功能强大 ...
- remote_addr和x_forwarded_for
做网站时经常会用到remote_addr和x_forwarded_for这两个头信息来获取客户端的IP,然而当有反向代理或者CDN的情况下,这两个值就不够准确了,需要调整一些配置. 什么是remote ...
- canvas draw a image
var c = context.getContext("2d"); var cimg = new Image(); cimg.src = "img path"; ...
- HttpURLConnection 直接发送soap消息调用webservice
httpConn = (HttpURLConnection) new URL(urlString).openConnection(); httpConn.setRequestProperty(& ...
- AndroidManifest.xml
一.关于AndroidManifest.xml AndroidManifest.xml 是每个android程序中必须的文件.它位于整个项目的根目录,描述了package中暴露的组件(activiti ...
- Objective-C中的@property和@synthesize用法
@代表“Objective-C”的标志,证明您正在使用Objective-C语言 Objective-C语言关键词,@property与@synthesize配对使用. 功能:让编译好器自动编写一个与 ...
- Mono addin 学习笔记 5 TypeExtensionPoint
1. Attribute声明方式 定义扩展点: [TypeExtensionPoint]public interface ICommand{ void Run();} 定义扩展: [Ex ...