在Java Web项目中,如何在URL请求中获取(如果可能)"HTTP锚点"部分?例如,当请求URL为http:// localhost:8080/servlet/page.htm?param1 = value1¶m2 = value2#section时,我希望能够识别该#section部分.
public void doGet
(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
// ...
System.out.println("QueryString = " + request.getQueryString());
// ...
}
Run Code Online (Sandbox Code Playgroud)
上面的例子中产生的子前述的#,在这种情况下:param1=value1¶m2=value2.有没有办法在符号后提取URL的一部分#?
如果这有用,我正在使用Apache Click框架.
Jac*_*cob 11
我认为锚点部分不会发送到服务器.它仅由浏览器处理.也许你可以使用JavaScript提取它.
根据RFC 1808:
请注意,片段标识符(以及它之前的"#")不被视为URL的一部分.
来自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
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7066 次 |
| 最近记录: |