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>