JSP in the path

First, the client path: in the browser parses the path;

   1. absolute path: /servletDemo/css/style.css;

    // Ahead there was a slash, and must be added to the project name;

    <%= requset.getContextPath() %>/css/style.css

  2. The relative path: CSS / the style.css;

    ../style.css: in the current path of the upper level looking for style.css

Second, the server route: the server parsed path;

   1. absolute path: /css/style.css;

    // absolute path to the server will automatically add the project name, the server absolute path written without any increase in the project name;

  2. The relative path: CSS / the style.css;

    // server will generally direct path wrong error;

Third, the absolute path comparison:

  1. Client absolute path: http: // localhost: 8080 /

  2. The absolute server path: http: // localhost: 8080 / servletDemo /

Note: unified use an absolute path, but be aware that different services and client's writing;

 

Guess you like

Origin www.cnblogs.com/Tractors/p/11260371.html
jsp