我怎样才能读取java servlet中的html锚点? [英] How can i read html anchor in java servlet?

查看:224
本文介绍了我怎样才能读取java servlet中的html锚点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从请求中获取所有参数,包括#后面的内容。
例如:
请求: http:// myserver / m#q = abc
我需要我的服务器在#之后获取所有参数,因为它们位于?之后。
我该怎么做?
10x,
Koby

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

推荐答案

锚定或URL片段在 RFC 1738 在请求资源时不会由客户端发送到服务器。其基本原理是使用片段URL来标识资源中的位置,而不是服务器上的不同资源。为了识别资源中的位置,客户端需要从服务器获取完整的资源,并且该过程不需要传输关于片段的信息(因为它对服务器没有任何意义)。

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).

如果您希望使用包含片段的URL通过查询字符串提交信息,则必须确保查询字符串位于URL片段的前面。如果您自己构建请求,这可能是您的客户端代码中的一个错误。如果您可以负担得起,请将请求构建逻辑留给浏览器。

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.

如果您希望将片段字符(#)发送到服务器,那么您我们需要将它编码到查询字符串中,或​​者当客户端(浏览器)将请求发送到服务器时,它将简单地忽略该部分的URL。

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


  1. JSP Servlet定位器

  2. 如何在php中#之后获取URL的锚部分

这篇关于我怎样才能读取java servlet中的html锚点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆