`

关于javaweb地址栏技巧

 
阅读更多

例如:假设我们当前的地址是http://www.sina.com/admin/detail.jsp?id=5&type=7

HttpServletRequest request;
request.getRequestURL()得到的值是http://www.sina.com/admin/detail.jsp
request.getQueryString()得到的值是 id=5&type=7
request.getServletPath();//得到的值是 /admin/detail.jsp
request.getParameter("id") 5
request.getParameter("type")7
前台js:
location.search()<wbr>得到<wbr></wbr></wbr>id=5&type=7
访问的相对地址
 
会跳转到 http://www.sina.com/login.jsp
替换第一个"/"后面的内容
 
会跳转到<wbr></wbr>http://www.sina.com/admin/login.jsp
替换最后一个"/"后面的内容
分享到:
评论
发表评论

文章已被作者锁定,不允许评论。

相关推荐

Global site tag (gtag.js) - Google Analytics