参考:https://blog.csdn.net/xqhys/article/details/68486215
eg:
window.location.href="/user/update?id=''aaa"&name="sdsad"
*******************************************
//页面数据回显
//从当前路径 拿到id //http://localhost:8099/user/toupdate.action?id=17
//获取Location对象的search属性值
var searchStr = location.search;
//由于searchStr属性值包括“?”,所以除去该字符
searchStr = searchStr.substr(1);
//debugger;
//将searchStr字符串分割成数组,数组中的每一个元素为一个参数和参数值
var searchs = searchStr.split("&");
//获得第一个参数和值
var ids = searchs[0].split("=");
$http.get("/user/update/"+ids[1])
.then(function (response) {
alert(response.data);
$scope.user = response.data;
});
获取当前路径上的参数
<html>
<head>
<title>使用Location对象属性获取提交数据</title>
</head>
<body>
<script language="JavaScript" type="text/javascript"> //获取Location对象的search属性值
var searchStr = location.search; //由于searchStr属性值包括“?”,所以除去该字符
searchStr = searchStr.substr(); //将searchStr字符串分割成数组,数组中的每一个元素为一个参数和参数值
var searchs = searchStr.split("&"); //获得第一个参数和值
var address = searchs[].split("="); switch (address[])
{
case "beijing":
document.write("您选择的地址为:北京<br>");
break;
case "shanghai":
document.write("您选择的地址为:上海<br>");
break;
case "shenzhen":
document.write("您选择的地址为:深圳<br>");
break;
} //获得第二个参数和值
var sex = searchs[].split("=");
switch (sex[])
{
case "men":
document.write("您选择的性别为:男<br>");
break;
case "women":
document.write("您选择的性别为:女<br>");
break;
} </script> </body>
</html>