1. 程式人生 > >關於UTL會自動轉碼的問題 %自動轉換為%25

關於UTL會自動轉碼的問題 %自動轉換為%25

最近在URL傳遞引數的時候遇到Url自動將%轉化為%25 而我必定需要這個引數,我看過網上的方法

1.修改請求為POST請求(但是我的就是POST請求...實際我的沒有效果)

2.封裝為URL類..我也試了..

3.修改伺服器端接收(emmmmmmm 我是用作爬蟲的...所以伺服器我是管不著了)

下面看下我的方法吧:

實際要傳的值:

epdfcnnrD%2B79b2YRpO65FQDDn6%2FKWNkMRuJMakVKpEvWCu9l18MMaMRmMi2fMApJMgAntByk9mOTJfgkjLbu8ZkHM13fdexbRgjTR2xqbxkAfuG5%2FKvo2E0P8BNGLXB%2BJBa%2FU%2BSEyzOQHyh40axhgo2jLON5qddUN%2BT6aRLLROZNh1QZRkgZOCwpRnrP0dFvHYfJIFKXOcV5SqUvH10ilmPW1pPpwmwV9lmXZSB1T2LM67k%2FVf00t3uTGJyghsJ08fPkmJFmOYFKFdA3e7r%2BMw%3D%3D

請求時候的值:

epdfcnnrD%252B79b2YRpO65FQDDn6%252FKWNkMRuJMakVKpEvWCu9l18MMaMRmMi2fMApJMgAntByk9mOTJfgkjLbu8ZkHM13fdexbRgjTR2xqbxkAfuG5%252FKvo2E0P8BNGLXB%252BJBa%252FU%252BSEyzOQHyh40axhgo2jLON5qddUN%252BT6aRLLROZNh1QZRkgZOCwpRnrP0dFvHYfJIFKXOcV5SqUvH10ilmPW1pPpwmwV9lmXZSB1T2LM67k%252FVf00t3uTGJyghsJ08fPkmJFmOYFKFdA3e7r%252BMw%253D%253D

明顯在傳遞值的時候發生了自動轉碼的事情..採用先解碼的方式就解決了

String s="epdfcnnrD%2B79b2YRpO65FQDDn6%2FKWNkMRuJMakVKpEvWCu9l18MMaMRmMi2fMApJMgAntByk9mOTJfgkjLbu8ZkHM13fdexbRgjTR2xqbxkAfuG5%2FKvo2E0P8BNGLXB%2BJBa%2FU%2BSEyzOQHyh40axhgo2jLON5qddUN%2BT6aRLLROZNh1QZRkgZOCwpRnrP0dFvHYfJIFKXOcV5SqUvH10ilmPW1pPpwmwV9lmXZSB1T2LM67k%2FVf00t3uTGJyghsJ08fPkmJFmOYFKFdA3e7r%2BMw%3D%3D";
    String keyWord = URLDecoder.decode(s, "GBK");