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

时间:2014-12-06 14:43:20

标签: java servlets

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

网址类似于www.mydomain:8080 / SMP /帐户/显示/主题#M7

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

仅供参考我对设置引用者有限制。 有没有其他方法来获取完整的URL。

1 个答案:

答案 0 :(得分:2)

您无法从HttpServletRequest获取url片段标识符,因为它实际上并未传递给服务器,而是仅供客户端使用。

HttpServletRequest fragment identifier的快速Google应该确认,包括:

How to get the URL fragment identifier from HttpServletRequest

How to detect Fragment identifiers in Url Mappings?

相关问题