Action in form and understanding of <url-pattern>

Source: Internet
Author: User

First, <form action= "Test/login" method= "POST" >

There are two ways to express in action:

1, "/test/login" description is relative to the Web server root directory, can be understood as Http://localhost:8080/Test/Login

2. The "Test/login" description is relative to the root directory of the current Web application and can be understood as the HTTP://LOCALHOST:8080/project name/test/login

Ii. @WebServlet (name= "Login", urlpatterns={"/test/login"})

Urlpatterns and <url-pattern> have the same effect

Urlpatterns represents the path to the servlet, that is, when the URI is: http://localhost:8080/the project name/test/login? Name= "", the Web container invokes a servlet with the name login as a service to the user.

So the action is corresponding to the urlpatterns, that is, the URL in the action is required to fill in the URL in the Urlpatterns.

A few additional notes:

1. When HTML is in the Webroot/html folder, the URL in the action needs to be ".. /test/login "means to change the path to" http://localhost:8080/project name/", otherwise the URL will be" http://localhost:8080/project name/HTML/test/login "

2, when urlpatterns={"/test/login"}, if you want to use Response.sendredirect (URL) in its decorated servlet, the URL will be http://localhost:8080/project name/ Test/url, the URL is added under test/. This is necessary according to the actual situation, so that url= ". /"+url.

Action in form and understanding of <url-pattern>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.