Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In spring MVC, how to get full request URL including the fragment, like http://stackoverflow.com/myquestion#test=1234

I want to know how to get full request url I need #test=1234 but using HttpServletRequest request.getRequestURI() or request.getRequestURL().toString() return path only, like https://stackoverflow.com/myquestion Help me

like image 342
user1662015 Avatar asked Nov 30 '25 09:11

user1662015


2 Answers

#test=123 is called an Anchor. And Anchors are not submitted to the server, they only reside in the Broswer

@see:

  • How to get the anchor name in HTTP GET?
  • Retrieving Anchor Link In URL for ASP.Net
like image 178
Ralph Avatar answered Dec 03 '25 02:12

Ralph


Anchors or URL fragments are not sent by the client to the server when requesting for a resource. The anchor's or fragment's are utilized to identify a location within a resource and not a different resource on the server.

Fragment URL is not part of the URL. You can get the anchor using javascript & save them in cookies to retain them.

var anchor = window.location.hash;
like image 34
Jeevan Patil Avatar answered Dec 03 '25 02:12

Jeevan Patil