jsp中頁面的跳轉常常需要帶一些參數,不是前後臺分離,要自己做了。所以找到了如何獲取URL中參數值的方法,這是目前爲止小編在本項目中用到最多的方法。
<script type="text/javascript">
function GetQueryString(name)
{
var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if(r!=null)return unescape(r[2]); return null;
}
function addGoods(){
alert(GetQueryString("seckillId"));
window.location.href = BASE_URL +"/back/busiGoodsParam/add?styleId="+GetQueryString("styleId");
}
</script>