user1662015
user1662015

Reputation: 31

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

Upvotes: 3

Views: 2589

Answers (2)

Ralph
Ralph

Reputation: 120811

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

@see:

Upvotes: 5

Jeevan Patil
Jeevan Patil

Reputation: 6079

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;

Upvotes: 2

Related Questions