There are two types of Ajax URLs, one is absolute and the other is a relative path.
Absolute path: includes the full request path of the protocol name, host address, port, Web project name, and so on. For example: $.ajax ({ URL: "Http://localhost:8080/webname/test"}); Benefits: For example, Ajax in a Weba project needs to request services from a Webb project, You must use an absolute path. Cons: Using an absolute path requires the name of an ancient geographic Web project, and if the Webb Project is renamed, the corresponding Ajax request needs to be modified. Two, relative path: No protocol name, host address, port, Web project name, only the requested path is required. Assumption: Project path: Http://localhost:8080/webname page path:/webname/index.html (Page a),/webname/test/test.html (page b) Request path:/request/ Ajaxtest,request/ajaxtest 1, if the request path begins with a root path, whatever Ajax is on the page, the request is relative to the root path of the server, and the final request path is: http://localhost:8080/ Request/ajaxtest For example: $.ajax ({ URL: "/request/ajaxtest"}); the reason: Starting with "/" is to indicate that the request is based on the root path from the server, that is, the path that is not relative to the HTML.  2, if the request does not start with a root path (common), then the request path is relative to the path where the HTML resides. a, if requested on page A, the final request path is: Http://localhost:8080/webname/request/ajaxtest. // /webname/index.html page $.ajax ({ URL: "Request/ajaxtest" }); reason: The index.html page corresponds to a path of "/webname/", So the URL following this path is the final request path. B, if requested on page B, the final request path is:/httpLocalhost:8080/webname/test/request/ajaxtest. // /webname/test/test.html page $.ajax ({ URL : "Request/ajaxtest" }); Cause: The path to the test.html page is "/webname/test/", so the URL should be followed by the Test level. Environment Description Web server: Tomcat7mvc frame: Springmvc above content, are based on the environmental testing self-summed up, and there is no theoretical basis, if there are errors please leave a message.
The AJAX request path summary under Tomcat