在URL中传递包含'%'的参数? [英] Pass a parameter containing '%' in URL?
问题描述
在传递我的网址时,例如:8000 / something.jsp?param1 = update& param2 = 1000& param3 = SearchString%& param4 = 3
,I我收到以下错误:
While passing my url, for example something:8000/something.jsp?param1=update¶m2=1000¶m3=SearchString%¶m4=3
, I am getting following error:
Bad Request
Your browser sent a request that this server could not understand.
我知道 SearchString%
我需要哪些传递作为参数,有问题。然后如何在URL中传递包含'%'的
参数
I know SearchString%
which I need to pass as a parameter, has the issue. Then how to pass a
parameter containing '%' in URL??
推荐答案
使用%25代替%
在URL中%具有转义字符的特殊含义
Use %25 in place of % In URLs % has a special meaning as an escape character
像(空格)这样的特殊字符可以编码为%20(空格的ascii代码/ 32十六进制)
Special characters like (space) can be encoded like %20 (the ascii code for space/32 in hex)
因此百分号本身必须使用%的十六进制代码编码,恰好是25
Therefore a percent sign itself must be encoded using the hex code for % which happens to be 25
您可以使用 http://www.asciitable.com/ 查找相应的十六进制代码。 hx列
You can use http://www.asciitable.com/ to look up the appropriate hex code under the hx column
或者,如果您以编程方式(即使用javascript)执行此操作,则可以使用内置函数 escape()
喜欢转义('%')
Alternatively, if you are doing this programatically (ie. with javascript) you can use the builtin function escape()
like escape('%')
这篇关于在URL中传递包含'%'的参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!