The only way to develop: absolute path and relative path

Struts2 difficult points
    1. Set up the Struts2 development environment (import the necessary jar packages for the project; register the Struts2 startup items in web.xml; establish constraints for struts.xml)

    2. Obtain ServletAPI from Action, understand file path and master Tomcat deployment web project

    3. Learn to find struts-default.xml and default.properties configuration files

    4. OGNL and value stack, dynamic method invocation, type conversion, data verification, interceptor, file upload and download, token mechanism, annotation development


Absolute path * Local absolute path: the path with the drive letter and omitting the file protocol, such as file:///D:/images/flower.jpg

    * Network absolute path: the path with http access protocol, such as http://127.0.0.1/images/grass.jpg

Relative path
    * Relative path means that the actual path of the given path can be changed according to the difference of the reference path. Accurate positioning can be achieved according to the given path under the condition that the reference path remains unchanged, and the positioning cannot be achieved if the reference path changes.

    * The relative path starting with a slash can be divided into the foreground relative path and the background relative path according to the different files in the path.
    ① Front-end relative path: the path included in the front-end code that can be parsed by the browser. The reference path is the root path of the Web server, such as http://127.0.0.1:8080/
        Example: img src="" in HTML, a href="", form action=""; background-image: url("") in CSS; and window.location.href="" in JavaScript are all relative to the foreground.

    ② Back-end relative path: the path included in the code or file that is parsed by the server, such as http://127.0.0.1:8080/projectName
        Example: the path in the Java code, the path in the dynamic part of the JSP file, the path in the xml file Path, etc. (xml file can be loaded into memory by Java for analysis).

  • The relative path that does not start with a slash refers to whether it is a front-end relative path or a back-end relative path, the reference path is the access path of the current resource, not the save path of the current resource.

  • The JSP file comes with a dynamic path equivalent to ${pageContext.request.contextPath}
    <%
    String path = request.getContextPath();
    String basePath = request.getScheme()+": //"+request.getServerName()+ ":"+request.getServerPort()+path+"/";
    %>

Guess you like

Origin blog.csdn.net/qq_44965393/article/details/112243849