在JSPF

时间:2015-07-13 07:00:17

标签: java jsp servlets wcs

我有一个类似于此http://localhost/webapp/wcs/stores/servlet/ProductDisplay?expDataType=CatalogEntryId&catalogId=10351&urlRequestType=Base&productId=14311&expDataUniqueID=14311&errorViewName=ProductDisplayErrorView&urlLangId=-1&langId=-1&storeId=11001

的网址

我如何获得完整的网址?

我尝试了request.getURL.toString()request.getQueryString()request.getAttribute("javax.servlet.forward.request_uri")

但没有什么能给出完整的路径。

有人可以帮忙吗?

2 个答案:

答案 0 :(得分:1)

你可以试试这个

 String completeURL = request.getRequestURL().toString() +"?"+ request.getQueryString();

或根据您的申请进行自定义。

即使你可以参考:how to get full path of URL including multiple parameters in jsp

希望它有所帮助, 谢谢,

答案 1 :(得分:0)

考虑到完整的URL甚至没有到达应用程序服务器,因为浏览器首先打开一个套接字到根地址,然后与其余部分发出HTTP请求。

考虑

  

http://www.mywebserver.com:12345/mypage1?param=value

浏览器首先打开一个套接字到 IP地址www.mywebserver.com :12345,然后发出一个只包含 mypage1?param = value 的HTTP GET请求。

尽管如此,HttpServelRequest.getRequestURL()在某些情况下可以奏效。如果不是,您应该在Web应用程序中知道服务器的地址,或者通过隐藏字段传递它。

相关问题