怎么样获得当前的页的URL地址?

sanshao526 2003-04-08 01:03:53
怎么样获得当前的页的URL地址?
...全文
32 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
fibczh 2003-04-09
  • 打赏
  • 举报
回复
http://localhost:7001/myservlet/somepath/test?someparam=somevalue
request.getPathInfo():返回/somepath/test
request.getRequestURL():返回http://localhost:7001/myservlet/somepath/test
request.getRequestURI():返回/myservlet/somepath/test
request.getServletPath():返回/myservlet
request.getQueryString():返回someparam=somevalue

我只需返回http://localhost:7001/myservlet/somepath用何方法?
谢谢!
黑马 2003-04-08
  • 打赏
  • 举报
回复
学习
aleccheung 2003-04-08
  • 打赏
  • 举报
回复
jsp:
request.getRequestURI();//从根目录起 /Expert/topic/1633/1633171.xml?temp=.7674372
request.getQueryString(); //后边参数 temp=.7674372

JavaScript
window.location;
的结果
http://expert.csdn.net/Expert/topic/1633/1633171.xml?temp=.7674372


signboy 2003-04-08
  • 打赏
  • 举报
回复
javascript:
location.href
flashroom 2003-04-08
  • 打赏
  • 举报
回复
举例:
http://localhost:7001/myservlet/somepath/test?someparam=somevalue
request.getPathInfo():返回/somepath/test
request.getRequestURL():返回http://localhost:7001/myservlet/somepath/test
request.getRequestURI():返回/myservlet/somepath/test
request.getServletPath():返回/myservlet
request.getQueryString():返回someparam=somevalue
mim 2003-04-08
  • 打赏
  • 举报
回复
request.getPathInfo()
编程指南针 2003-04-08
  • 打赏
  • 举报
回复
UP
mindon 2003-04-08
  • 打赏
  • 举报
回复
request.getRequestURL().toString()

81,094

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧