Java Web Path analysis

Source: Internet
Author: User

Absolute path: The path that starts with/begins with the absolute path, and the absolute path is directly spliced on the relative path to get the final path.
Relative path: A path that does not start with/begins with a relative path, and the relative path is calculated from the path to the final path based on the current route.
Hard drive Path: The path that begins with a drive letter is called the hard drive path. Which path is which is the path. There is no question relative to WHO

Virtual path:--use absolute path when writing virtual path
If the path is for the browser, the path is relative to the virtual host, so you need to write the name of the Web App
If the path is a server, this path is relative to the Web app, so you can save the name of the Web App
<a href= "/day04/..." >
<form action= "/day04/..." >

Response.setheader ("Location", "/day04/....");
Response.setheader ("Refresh", "3;url=/day04/...");
Response.sendredirect ("/day04/...");
Request.getrequestdispathce ("/index.jsp"). Forward ();
Request.getrequestdispathce ("/index.jsp"). include ();


True path:--use relative paths when writing real paths
According to the principle, concrete analysis of specific problems

Servletcontext.getrealpath ("Config.properties");//--to a path relative to the Web application directory
Classloader.getresource (".. /.. /config.properties ");//--to a path that loads the directory relative to the class

File File = new file ("Config.properties");//--startup directory relative to the program
New InputStream ("Config.properties");//--startup directory relative to the program

Java Web Path analysis

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.