<script >
$(function(){
alert("haha");
var str = 'http://www.baidu.com?name=张三&age=18';
console.log(str);
a(str);
function a (s){
var h = encodeURI(s);
console.log(h);
var y = encodeURIComponent("张三");
console.log(y);
var g = "www.baidu.com?name=";
var i = encodeURIComponent("张三");
console.log(g+i);
</script>
Java正确URL解码方式:URLDecoder.decode
Exception in thread "main" java.lang.IllegalArgumentException: URLDecoder: Illegal hex characters in escape (%) pattern - For input string: "u9" at java.net.URLDecoder.decode(URLDecoder.java:194) at com.hbzx.controller.PayResultController.main(PayResultController.java:253)