In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
In this article, the editor introduces in detail how the server finds the required servlet through URL. The content is detailed, the steps are clear, and the details are handled properly. I hope that this article "how the server finds the servlet you need through URL" can help you solve your doubts.
Web.xml is also called the project deployment file (some tutorials will call it the DD file, or Deployment Descriptor, meaning deployment description). This file consists of a stack of xml tags that configure the project through the data provided by these tags. This includes a pair of tags associated with servlet and url (determined by both tags), as shown in the following code:
HelloServlet com.example.demo.HelloServlet helloServlet / hello
There are two child tags under the servlet tag, one defines the name of a servlet (used in the deployment file, which can be used as a nickname for the deployment file to servlet), and the other associates the name of the servlet with a specific servlet (remember, there is a classes folder under the WEB-INF folder that stores the compiled servlet, while the web.xml and WEB-INF folders are siblings). The purpose of the servlet tag is to define a deployment name for a specific servlet.
Then there is the servlet-mapping tag, which also has two tags under it, one pointing to the previously defined servlet deployment name and the other pointing to a url.
Through these two tags, web.xml corresponds servlet to url one by one. When the browser sends a request to the server, the server parses the url, then looks for the corresponding servlet in the deployment file, and forwards the request to the servlet for processing.
A new way of association
In the servlet3.0 version, you can annotate a servlet with @ webservlet, and you can configure the deployment name and the corresponding url for this servlet. As follows:
@ WebServlet (name = "helloServlet", value = "/ hello-servlet") public class HelloServlet extends HttpServlet {public void doGet (HttpServletRequest request, HttpServletResponse response) throws IOException {/ / here is the get method}
Using annotations can quickly configure the project, but it is not conducive to the deployment of the project.
After reading this, the article "how to find the servlet that the server needs through URL" has been introduced. If you want to master the knowledge of this article, you still need to practice and use it yourself. If you want to know more about related articles, welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.