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>