Is there any way to get the URL of the resource which is currently handled? Suppose I'm in Parent class (I also have grand-parent handler, parent-handler, child handler). And the full URL looks like this: /smt1/smt2/smt3/parent/child.
有沒有辦法獲取當前處理的資源的URL?假設我在Parent類中(我還有祖父處理程序,父處理程序,子處理程序)。完整的URL如下所示:/ smt1 / smt2 / smt3 / parent / child。
I know that there is a way to get the full request URL.
我知道有一種方法可以獲得完整的請求URL。
But is there any way to obtain /smt1/smt2/smt3/parent part in Parent handler?
但有沒有辦法在父處理程序中獲取/ smt1 / smt2 / smt3 / parent部分?
0
UriInfo
is the class you're looking for. To get your current URL/URI you use:
UriInfo是您正在尋找的課程。要獲取您當前使用的URL / URI:
@Context
private UriInfo info
@Path("/a/b/c")
@GET
public String get() {
return "URL is: " + this.info.getRequestUri();
}
本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2012/08/29/7256deb355680ec7158c6c96a5e3c900.html。