java - Is it possible to get the absolute request url without path parameters -
i trying request url without values of path parameters it.
consider complete url
url: http://localhost:8080/aaa/mock/abcd/1234/true path parameters: abcd, true output needed: /aaa/mock/abcd my web service method looks this.
@path(value = "/aaa/mock") @component public class mockservice { private static log log = logfactory.getlog(mockservice.class); //address @get @path(value = "/{mockrequest}/{status}") @produces(mediatype.json) public string mockengagement(@context containerrequestcontext request,@pathparam("mockrequest") string mockrequest,@pathparam("status") string status ) { log.info("the mock url is"+request.geturiinfo().getrequesturi()); log.info("the mock url is"+request.geturiinfo().getabsolutepath()); log.info("the mock url is"+request.geturiinfo().getbaseuri()); log.info("the mock url is"+request.geturiinfo().getmatcheduris()); **//out put needed /aaa/mock/abcd** return "ajaja"; } } none of above calls return required info.
i thinking if there generic process desired output irrespective of number of path parameters.
any such methods.
try uriinfo#getpath(), uriinfo#getpath(boolean), or uriinfo#getpathsegments(). boolean argument whether path should encoded or not.
https://jersey.java.net/apidocs/2.3.1/jersey/index.html
you absolute path , base path , use uri#relativize(uri).
Comments
Post a Comment