Servlet Path Problem

Relative path leading slash

We can set the relative path, and the browser or server, to help us to convert a relative path into an absolute path. Absolute path in order to obtain access to resources.
Reception Path:
refers to the route: the current root path of the web server: http: // localhost: 8080
absolute reference path = path + relative path
so I want to access a resource must be added to the current project name

<a href="/项目名/当前资源路径"></a>

Background Path:
refers to the route: Follow the path of the current web application: http: / localhost: 8080 / project name
absolute path = reference path + relative path
under normal circumstances can be accessed directly
Note: sendRedirect ( "/ other") not visit, he the reference path is http: / localhost: 8080

request.getRequestDispatcher("/other").include(request, response);

xml file:
refers to the route: Follow the path of the current web application: http: / localhost: 8080 / project name
absolute path = path + relative path reference

<url-pattern>/hps</url-pattern>

The beginning of the path to a relative path name

Foreground and background path:
reference path: the current access path resource path: http: / localhost: 8080 / project name
absolute path = reference path + relative path to
xml file:
Because the xml configuration file, the request does not exist, so there is no resource path, We can only begin with a slash.

Published 114 original articles · won praise 8 · views 5487

Guess you like

Origin blog.csdn.net/OVO_LQ_Start/article/details/104732869