Java 如何在HTTP get中获取锚点名称?

Java 如何在HTTP get中获取锚点名称?,java,servlets,Java,Servlets,在JavaWeb项目中,如何(如果可能的话)获取URL请求中的“HTTP锚”部分? 例如,当请求URL为时,我希望能够识别#部分部分 public void doGet (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // ... System.out.println("QueryString = " + request.getQuery

在JavaWeb项目中,如何(如果可能的话)获取URL请求中的“HTTP锚”部分? 例如,当请求URL为时,我希望能够识别
#部分
部分

public void doGet
(HttpServletRequest request, HttpServletResponse response) 
throws ServletException, IOException 
{
  // ...
  System.out.println("QueryString = " + request.getQueryString());
  // ...
}
上面的示例在
#
前面生成子字符串,在本例中:
param1=value1¶m2=value2
。有没有办法提取
#
符号后的URL部分


如果这有任何用处,我使用的是Apache Click框架。

我认为锚定部分不会发送到服务器。它仅由浏览器处理。也许您可以使用JavaScript提取它

根据:

请注意,片段标识符(及其前面的“#”)是 不被视为URL的一部分


看起来你是对的,它没有发送到服务器:
var url=window.location;
var anchor=url.hash; //anchor with the # character  
var anchor2=url.hash.substring(1); //anchor without the # character