Q: There are statements like this
:
String Path = Request.getcontextpath ();
String basepath = request.getscheme () + "://" +request.getservername () + ":" +request.getserverport () +path+ "/";
<base href= "<%=basePath%>" >
Answer: This statement is used to assemble the relative path of the current page.
<base href= "..." > is the root path used to indicate the relative path of the current page.
For example, there is a connection inside the page, and the complete path should be http://localhost:80/myblog/authen/login.do
where http://server/is the basic path of the server, MyBlog is the name of the current application, then my root path should be so http://localhost:80/myblog/.
with this <base ... > after the connection of my page content, I do not want to write the full path, I just write authen/login.do on it. The server will automatically assemble the path specified by <base ...> and the relative path within the page to form the full path.
If there is no such <base...>, then the link of my page must write the full path, otherwise the server will not be found.
Request.getschema () can return the protocol used by the current page, which is "http" in the example above
Request.getservername () can return the name of the server on which the current page is located, or "localhost" in the example above
Request.getserverport () can return the port used by the server on which the current page is located,
Request.getcontextpath () can return the name of the application in which the current page is located, which is the myblog in the example above
These four assembled, is the current application of the follow-up path
String basepath = request.getscheme () + "://" +request.getservername () + ":" +request.getserverport () effect