如何从HttpServletRequest获取包含#的完整URL

如何从HttpServletRequest获取包含#的完整URL

本文介绍了如何从HttpServletRequest获取包含#的完整URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的示例应用程序中,我正在显示一些记录,基于#am向下滚动到特定主题。但要编辑该消息,用户必须登录。但是在基于servlet的请求对象的signin页面中构建目标URL时,我没有得到#in url。

In my sample application i am displaying some records, based on # am scrolling down to a particular topic. But to edit that message user has to logon. But while constructing destination url in signin pagebased on request object of servlet am not getting the # in url.

URL看起来像www.mydomain:8080 / SMP / Account / display / topic#M7

URL looks like www.mydomain:8080/SMP/Account/display/topic#M7

   public static String getFullURL(HttpServletRequest request) {
    StringBuffer requestURL = request.getRequestURL();//**http://xyz:8080/SMP/Account/display/topic**
    String queryString = request.getQueryString();
  .....
   }

仅供参考我对设置有限制引荐。
有没有其他方法可以获得完整的网址。

FYI i have a restriction on setting referer.Is there any other-way to get full url.

推荐答案

您无法从 HttpServletRequest 中获取url片段标识符实际上并没有传递给服务器,它只适用于客户端。

You cannot get the url fragment identifier from the HttpServletRequest as its not actually passed along to the server, it is for the client only.

快速Google for HttpServletRequest片段标识符应该确认,包括:

A quick Google for HttpServletRequest fragment identifier should confirm that, including:

这篇关于如何从HttpServletRequest获取包含#的完整URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 12:11