Definition and mapping servlet in web.xml file (13)

xiaoxiao2021-03-06  57

A servlet instance (servlet instance) must first be defined in the servlet web.xml file in the Web.xml file, and then map this instance to one or more URL Patterns.

1. Define the servlet instance: element defines a servlet instance. The element must contain and two sub-elements, or other initialization parameters may also be included. element defines the unique name of the servlet instance. Each servlet instance must have a unique name, which is only used to match the URL mapping of this instance, so it is not necessary to consistent with the servlet class or servlet's URL. element tells the Servlet container how to build an instance of a servlet class. The element contains two parts, contains the class name of the servlet, and the class name of the Servlet class. For example: getStatus status.createstatusservlet Due to the name of the Servlet instance does not have to match the class name of the Servlet class. To load another instance of the same servlet class into a container, just another servlet instance name. For example: getStatus status.createstatusservlet

fullstatus status.createstatusservlet Each element is also available to any number of element. The container passes the parameters to their respective servlets. Like the command line parameters, the individual servlets require their respective parameter names and parameter values. E.g:

getStatus status.createstatusservlet Output Brief

fullstatus status.createstatusservlet Output Verbose A element can only define a servlet instance. In order to transfer the container to the servlet, a servlet must be mapped to one or more URLs or calls the names of other servlets or filters through this servlet.

转载请注明原文地址:https://www.9cbs.com/read-114731.html

New Post(0)