是否可以使用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发布于 2015-02-14 03:46:41
要获取域之后的所有内容,请使用uri
String path = request.uri();或者,如果您想删除查询字符串参数,可以使用path
String path = request.path();https://stackoverflow.com/questions/28504806
复制相似问题