例如:假设我们当前的地址是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
替换最后一个"/"后面的内容
解析HTTP请求与URL路径操作

本文详细解析了如何通过HttpServletRequest获取HTTP请求的URL、参数和查询字符串,并演示了如何根据URL路径进行替换操作。
3647

被折叠的 条评论
为什么被折叠?



