天天看點

url參數+,&,=,/等轉義編碼

  url出現了有+,空格,/,?,%,#,&,= 等特殊符号的時候,可能在伺服器端無法獲得正确的參數值。

案例:

<img src="BarCode39.aspx?barcodevalue=http://www.baidu.com.cn:8066/order/InputTrainingInfo_kcsj.aspx?TrainId=1&TrainMoney=900&t=2&w=500&h=500" id="imgEWM"/>       

  如果我們想讓barcodevalue的參數是http://www.baidu.com.cn:8066/order/InputTrainingInfo_kcsj.aspx?TrainId=1&TrainMoney=900,&t=2,&w=500,&h=500的情況下我們需要對等号進行轉義,否則伺服器端會預設把barcodevalue=http://www.baidu.com.cn:8066/order/InputTrainingInfo_kcsj.aspx?,TrainId=1,TrainMoney=900,&t=2,&w=500,&h=500。

url參數+,&amp;,=,/等轉義編碼

特殊符号轉義碼如下:

 符号                  url中轉義結果     轉義碼
   +               URL 中+号表示空格          %2B    
 空格      URL中的空格可以用+号或者編碼          %20 
   /               分隔目錄和子目錄       %2F 
  ?            分隔實際的URL和參數      %3F
  %                   指定特殊字元          %25 
  #                     表示書簽      %23
  &       URL 中指定的參數間的分隔符          %26
  =             URL 中指定參數的值        %3D

轉義後代碼:

<img src="BarCode39.aspx?barcodevalue=http://www.baidu.com.cn:8066/order/InputTrainingInfo_kcsj.aspx?TrainId%3D1%26TrainMoney%3D900&t=2&w=500&h=500" id="imgEWM"/>