1.URL special characters need to be escaped
2. Replace the space with a plus sign (+)
3. Forward slash (/) separator directory and subdirectories
4. Question mark (?) Separating URLs and queries
5. Percent semicolon (%) to develop special characters
6. #号指定书签
7.& Number Separator parameter
Reason to escape character:
If your form is submitted using the Get method, and the submitted arguments have special characters such as "&", if you do not do so, you will see the & as another parameter in the service side. For example
The action for the form is list.jsf?act=go&state=5
The value of Act and state can be obtained separately by Request.getparameter at commit.
If your intention is to act= ' go&state=5 ' This string, you must escape the & to get the exact value of the act on the server.
URL Escape Character principle:
Converts these special characters to ASCII, in the form of the ASCII code with a% character, that 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".
1.URL special symbol and corresponding hexadecimal value encoding:
2.
3.+ the + number in the URL indicates a space%2b
4. Spaces in the URL can be used with + or encoding%20
5./delimited directory and subdirectory%2f
6.? Separating the actual URLs and parameters%3f
7.% Specify special characters%25
8.# represents a bookmark%23
The separator between the parameters specified in the 9.& URL%26
10.= the value of the specified parameter in the URL%3d
The solution is as follows (take the + number as an example):
Method One, modify the client, the client with "+" in the parameters of the "+" all replaced with? %2b ", so that when the parameters are uploaded to the server side, you get" + ".
Method Two, modifies the server side, replaces the space with "+", this method only applies in the parameter to have? " + "No spaces in the case."
Example:
If the client is Clientstr=test+ok, then the value of a is test+ok;
Method Iii. Modify the server side to change the method of obtaining the parameters from Reuqest.getparameter to request.getquerystring (). substring (0), and then parse the resulting string.
Example:
If the client is Clientstr=test+ok, then the value of a is clientstr=test+ok, which needs to be parsed again,
A=a.? SUBSTRING (10), the value of a is Test+ok.
Attached: A JS, used to escape the special characters in the URL.
function UrlEncode (sStr) {return
escape (SSTR). Replace (/\+/g, '%2b '). Replace (/\ "/g, '%22 '). Replace (/\ '/g, '%27 ') . replace (/\//g, '%2f ');
}
If you are using replace (), use Name.replaceall ("\", "%20");
My solution:
JS Code
function Rstr (str) {
str=str.replace (/\+/g, "%2b");
return str;
}
function Selectarclista (fname) {
var posleft = ten;
var postop = ten;
window.open ("content_select_list.asp?f=" +fname+ "&k=" +escape (RSTR (Form1.tag.value)), "Selarclist", " Scrollbars=yes,resizable=yes,statebar=no,width=700,height=500,left= "+posleft+", top= "+posTop");
}
ASP-Side replacement code
Keyword=replace (keyword, "%2b", "+")
Perfect solution to the problem.