How to get the anchor name in HTTP GET?

前端 未结 1 767
日久生厌
日久生厌 2021-01-13 07:04

In a Java web project, how can I get (if possible) the \"HTTP anchor\" part in a URL request? For example, when the request URL is http://localhost:8080/servlet/page.htm?pa

1条回答
  •  借酒劲吻你
    2021-01-13 07:53

    I don't think the anchor part is send to the server. It is only processed by the browser. Maybe you can extract it using JavaScript.

    According to RFC 1808:

    Note that the fragment identifier (and the "#" that precedes it) is not considered part of the URL.

    From http://iwebdevel.com/2009/06/10/javascript-get-anchor-from-url/

    var url=window.location;
    var anchor=url.hash; //anchor with the # character  
    var anchor2=url.hash.substring(1); //anchor without the # character
    

    0 讨论(0)
提交回复
热议问题