什么是Spring中的Dispatcher Servlet? [英] What is Dispatcher Servlet in Spring?

查看:125
本文介绍了什么是Spring中的Dispatcher Servlet?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在此图片中(我来自 此处 ), HTTP 请求向 Dispatcher Servlet发送内容。

In this image (which I got from here), HTTP request sends something to Dispatcher Servlet.

我的问题是 Dispatcher Servlet 做了什么?

是否类似于从网络上获取信息页面并将其扔给控制器?

Is it something like getting the information thrown from the web page and throwing it to the controller?

推荐答案

DispatcherServlet 的工作是接收传入URI并找到正确的处理程序组合(通常是 Controller 类上的方法)和视图(通常是JSP),它们组合在一起形成应该在该位置找到的页面或资源。

The job of the DispatcherServlet is to take an incoming URI and find the right combination of handlers (generally methods on Controller classes) and views (generally JSPs) that combine to form the page or resource that's supposed to be found at that location.

我可能


  • 文件 / WEB-INF / jsp /页/回到Home.jsp

  • 以及类上的方法

@RequestMapping(value="/pages/Home.html")
private ModelMap buildHome() {
    return somestuff;
}


Dispatcher servlet 是知道在浏览器请求页面时调用该方法的位,并将其结果与匹配的JSP文件组合以生成html文档。

The Dispatcher servlet is the bit that "knows" to call that method when a browser requests the page, and to combine its results with the matching JSP file to make an html document.

它如何实现这一点因配置和Spring版本而异。

How it accomplishes this varies widely with configuration and Spring version.

最终结果也没有理由成为网页。它可以做同样的事情来找到 RMI 端点,处理 SOAP 请求,任何可以进入servlet的东西。

There's also no reason the end result has to be web pages. It can do the same thing to locate RMI end points, handle SOAP requests, anything that can come into a servlet.

这篇关于什么是Spring中的Dispatcher Servlet?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆