【发布时间】:2015-02-14 03:46:41
【问题描述】:
是否可以使用 Java 从 HTTP 请求中获取根域名之后的所有内容?
所以如果请求的 url 是 http://example.com/my-path 那么我想得到 my-path 的值
我正在使用 PlayFramework,所以如果有一个名为“Path”的标题或类似的东西,它应该更容易获得它:
String path = request.headers.get("path");
但是这个页面表明这样的事情不存在:
https://en.wikipedia.org/wiki/List_of_HTTP_header_fields
如果有不同的解决方案来获得相同的结果,那也将不胜感激。如果可能的话,它也会为这个问题提供一个解决方案:
http://stackoverflow.com/questions/28503129/redirect-example-com-to-www-example-com-in-playframework-1-2-x
【问题讨论】:
-
理想情况下只是根域之后的路径,但我想我也可以去掉域
-
这能回答你的问题吗?
标签: java http playframework http-headers