web.xml url-pattern learning

     The value in url-parttern is to alias the url.

      

      In this example, we open tomcat and create hello.html under %tomcat_home%webapps/root/, the code is as shown in the figure:

The path is shown in the figure:

  Run tomcat, enter http://localhost:8080/hello.html in the browser, you can see the following page:

  After entering these, click Submit:

  It can be found that the URL is: http://localhost:8080/TomcatTestqwead/HelloForm?name=asdfasdf&url=sdfasdf.

 

  We can now summarize: when we click the submit button, the action in the form tag is concatenated to the back of the url. In this example, the url of hello.html is: http://localhost:8080/hello.html, and the submitted url is: http://localhost:8080/TomcatTestqwead/HelloForm?name=asdfasdf&url=sdfasdf.

  Among them, TomcatTestqwead/HelloForm is the attribute value of action. ? is the spacer, and name=asdfasdf&url=sdfasdf is the attribute name and attribute value. And web.xml finds the servlet tag with the same servlet-name as the url-pattern through the same url-pattern as the attribute value of the action, finds the class of the servlet-class in it, and runs this class.

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324836973&siteId=291194637