I need to get all parameters from the request including what comes after "#". example: request: http开发者_运维问答://myserver/m#q=abc I need my server to get all parameters after "#" as they where after "?" How can i do that? 10x, Koby
Anchors or URL fragments as they are referred to in RFC 1738, are not sent by the client to the server, when requesting for a resource. The rationale is that fragment URLs are utilized to identify a location within a resource and not a different resource on the server. In order to identify the location in the resource, the client needs to fetch the complete resource from the server, and this process need not involve transfer of information about the fragment (as it does not mean anything to the server).
If you do wish to submit information via the query string using a URL containing a fragment, you will have to ensure that the querystring precedes the URL fragment. This might be a bug in your client-side code, if you're constructing the request on your own. Leave the request construction logic to the browser, if you can afford to do so.
If you do wish to send the fragment character (#) to the server, then you'll need to encode it in the query string, or the client(browser) will simply ignore that section of the URL when it sends the request to the server.
Related Questions on SO
- JSP Servlet anchor
- How to obtain anchor part of URL after # in php
Have in mind that anchors are a client-side concept so they shouldn't be used in the server side. Clients don't send the anchor data to the server, so you can't do this. Better use get parameters.
You can't do this. The URI spec says:
A reference to a particular part of a document may, including the fragment identifier, look like
http://www.myu.edu/org/admin/people#andy
in which case the string "#andy" is not sent to the server, but is retained by the client and used when the whole object had been retrieved.
精彩评论