Java processing URL in the special characters%, etc.
Source: Internet
Author: User
Reprint: http://www.blogjava.net/renyangok/archive/2007/01/12/93537.html Java processing Special characters in the URL (such as &,% ... The URL (uniform resoure Locator, Uniform Resource Locator) is the symbol of the unified positioning and management of resources in the Internet.
A complete URL includes the following:
1. Application of the agreement name, including Http,ftp,file and other signs
2. Resource positioning, is by (.) Segmentation and other network paths
3. Port number, according to the rule, the HTTP application port is the 80,telnet protocol application port is 23.
4. File paths in the server
5. Encoded position in the file
A complete URL is as follows:
Http://someuser:mypassword@www.some_server.com:8080/path/file.html
URL cannot display some special symbols, this time will use the encoding. The encoded format is: A percent semicolon followed by the ASCII (16) code value of the corresponding character. For example, the encoded value of a space is "%20". (ASCII reference)
Some characters have special meanings in the URL, and the basic encoding rules are as follows:
Special meaning hexadecimal value
1.+ represent spaces (you cannot use spaces in URLs)%20
2./delimited directory and subdirectory%2f
3.? Separating the actual URLs and parameters%3f
4.% Specify special characters%25
5.# represents a bookmark%23
The separator between the parameters specified in the 6.& URL%26
Encoding and decoding functions for URLs in Java
Java.net.URLEncoder.encode (string s) and Java.net.URLDecoder.decode (string s);
Encoding and decoding functions for URLs in JavaScript
Escape (string s) and unescape (string s);
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