The absolute path is the full path that includes the Server Protocol (in this example, http). For example, the full path of "Hong Neng online-computer Park" is http://www.hongen.com/pc/index.htm. if you want to link a document outside the site, use
String path = Struts2util.getservletcontext (). Getrealpath ("/");One, method one(1), Request.getrealpath ("/");//not recommended to get the root path of the project(2), Request.getrealpath (Request.getrequesturi ());//Get the path of the JSP, this
1. relative and absolute paths
There are three types of document paths: absolute path, root relative path, and document relative path.
The absolute path is the full path that includes the Server Protocol (in this example, HTTP). For example, the
Absolute Path:
is the path that starts with the letter, shaped like C:\windows\system32\cmd.exe
relative path:1, "./": Indicates the directory where the file is currently located. 2, ". /": Represents the top level of a directory for a file. 3, "
Turn from 49453953The following paths are described for Windows, and other platforms are not very well known for the time being.When you open a file in a py file that you write, you often see the following path:Open ('aaa.txt') open ('/data/bbb.txt'
Relative and absolute paths in C + + and the difference between a slash and a backslash
File path
Forward slash and back slash
Forward Slash, also known as the left slash, the symbol is "/", the backslash is also called the right slash, the symbol
Original: C # get relative pathFirst, get the path of the current file1. System.Diagnostics.Process.GetCurrentProcess (). Mainmodule.filenameGets the full path of the module, including the file name.2. System.Environment.CurrentDirectoryGets and
1. Obtain the path of the current file 1 . System. Diagnostics. process. getcurrentprocess (). mainmodule. filename: Obtain the complete path of the module, including the file name. 2 . System. environment. currentdirectory gets and sets the
ObjectiveCurrent project directoryWindows for E:\project\testpro\Linux for /project/testpro/Obtaining an absolute path condition in the Windows environmentUse A/B/C as the path to get the absolute path: new File ("a/b/c"). GetAbsolutePath ()The
First, get the path of the current file1. System.Diagnostics.Process.GetCurrentProcess (). Mainmodule.filenameGets the full path of the module, including the file name.2. System.Environment.CurrentDirectoryGets and sets the fully qualified directory
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.