[英]How to get the the URI path for javax.ws.rs.core.UriInfo with parameters instead of values
当我得到UriInfo.getPath()时 ,它返回getFoo / 12345 / enable (12345是id)。
我希望得到它, getFoo / id / enable 。
有一种直截了当的方法吗? 或者只是解决它的问题?
看看UrlInfo.getPathSegments()。 可能比“解析地狱”更容易。 :)
https://jersey.java.net/apidocs/1.8/jersey/javax/ws/rs/core/UriInfo.html#getPathSegments()
只需格式化您的第一个结果并用id
替换数值。
String path = "getFoo/12345/enable";
System.out.println(path.replaceAll("\\d+", "id"));
输出:
getFoo/id/enable
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.