解析请求URL时如何获取URL标签? [英] How do I get URL label when parsing request URL?

查看:212
本文介绍了解析请求URL时如何获取URL标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

URL可以在URL参数后面加上一个标有#符号的标签。
例如 http://example.com/foo/bar.jsp?p1=v1# test_label

URL can have a label, separated with a "#" sign, coming after the URL parameters. E.g. http://example.com/foo/bar.jsp?p1=v1#test_label

我希望label是request.getQueryString()的一部分,也是request.getRequestURL()。toString()的一部分。
但它似乎没有。

I would expect label to be part of request.getQueryString() and part of request.getRequestURL().toString(). But it doesn't seem to be there.

有没有办法从服务器端的HttpServletRequest检索标签值?

Is there a way to retrieve the label value from HttpServletRequest on server side?

推荐答案

我认为HTTP规范决定了锚点(这就是他们被称为什么?无论如何,哈希标志和之后的标签)不要传递给服务器,它们只是用于客户端滚动页面,或用于JavaScript。因此,除了让一个小脚本在加载页面时使用Ajax请求将其传递到服务器之外,你无法获得该值,但这不是很方便。

I think the HTTP spec decided that "anchors" (Is that what they're called? Anyway, the hash sign and the label that comes after) don't get passed to the server, they're just used client-side to scroll the page, or to be used in JavaScript. So there's no way you can get that value, other than having a little script passing it to your server with an Ajax request once the page is loaded, but that's not very convenient.

这篇关于解析请求URL时如何获取URL标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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