简体   繁体   English

查询Tomcat服务器的默认页面

[英]Query on default page of Tomcat server

This is a very basic question that i would like to understand. 这是我想要了解的一个非常基本的问题。

I am running Fresh Apache tomcat server on port 8080, and when i type URL http://localhost:8080 , i see that browser sends following request to tomcat. 我在端口8080上运行Fresh Apache tomcat服务器,当我输入URL http://localhost:8080 ,我看到浏览器向tomcat发送以下请求。

GET / HTTP/1.1
Host: localhost:8080
Connection: keep-alive
Cache-Control: max-age=0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.114 Safari/537.36
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8

I see the below http response with Content-type:text/html 我在Content-type:text/html看到了下面的http响应

在此输入图像描述

My question: 我的问题:

1) How / parameter of GET request mapped to this above html page as response at tomcat side, when tomcat server received this GET request? 1)当tomcat服务器收到此GET请求时, GET请求的/参数如何映射到上面的html页面作为tomcat端的响应? Is this something to do with below xml element in tomcat/conf/web.xml? 这与tomcat / conf / web.xml中的下面的xml元素有关吗? What is the flow on tomcat side after receiving this request? 收到此请求后,tomcat端的流量是多少?

<!-- The mapping for the default servlet -->
    <servlet-mapping>
        <servlet-name>default</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>

Tomcat Architecture Tomcat架构

A UML sequence diagram of the Request Process Flow will help you to understand it. 请求流程的 UML序列图将帮助您理解它。

Read more about the following sections directly from official document of Apache Tomcat 7: 直接从Apache Tomcat 7的官方文档中了解有关以下部分的更多信息:

  • Overview - An overview of the Tomcat server architecture with key terms and concepts. 概述 - 包含关键术语和概念的Tomcat服务器体系结构概述。
  • Server Startup - A detailed description, with sequence diagrams, of how the Tomcat server starts up. 服务器启动 - 有关Tomcat服务器如何启动的详细描述,以及序列图。
  • Request Process Flow - A detailed description of how Tomcat handles a request. 请求流程 - 有关Tomcat如何处理请求的详细说明。

It might help you to understand the url-pattern 它可能会帮助您理解url-pattern

Servlet Matching Procedure Servlet匹配程序

A request may match more than one servlet-mapping in a given context. 请求可以匹配给定上下文中的多个servlet映射。 The servlet container uses a straightforward matching procedure to determine the best match. servlet容器使用简单的匹配过程来确定最佳匹配。

The matching procedure has four simple rules. 匹配过程有四个简单的规则。

  • First, the container prefers an exact path match over a wildcard path match. 首先,容器更喜欢通配符路径匹配的精确路径匹配。

  • Second, the container prefers to match the longest pattern . 其次,容器更喜欢匹配最长的图案

  • Third, the container prefers path matches over filetype matches. 第三,容器优先于文件类型匹配的路径匹配。

  • Finally, the pattern <url-pattern>/</url-pattern> always matches any request that no other pattern matches. 最后,模式<url-pattern>/</url-pattern>始终匹配任何其他模式不匹配的请求。


Have a look at my post How does a servlets filter identify next destination is another filter or a servlet/jsp? 看看我的帖子servlet过滤器如何识别下一个目标是另一个过滤器还是servlet / jsp? for detailed description to understand it visually. 详细描述以直观地理解它。

对。这就是这个web.xml.this是Java Web应用程序中最重要的文件之一.GET的/ paramter由内置的servlet映射。为了更好地理解这一点你需要学习一点JSP / Servlet的事情

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM