jax-rs:jersey @pathparam 以一种方法获取先前的参数
jax-rs: jersey @pathparam to get previous param in one method
如何获取 on 方法中的最后一个路径参数。
@Path("{profile}/articles")
public getAllArticles(@PathParam("profile") String profile ){
}
@Path("{articleId}")
public getArticle(@PathParam("articleid") long id ){
}
I know how to get the recent path parameter like articleId
in method
getArticle
. but i want to get the previous path parameter in the getArticle
method.
ex: if the URL is /{profile}/articles/{articleId}
. How would I get values of both {profile}
and {articleId}
in same method
PS:我知道如果我从 UriInfo
获取路径,我可以通过打破 URL 来获得它
如果在 @Path
注释中指定,您可以获得多个 @PathParam
。
@Path("/{profile}/articles/{articleId: \d+}")
public Article readArticle(
@PathParam("profile") final String profile,
@PathParam("articleId") final long articleId) {
// "SELECT a FROM Article a WHERE a.profile=:profile AND a.id=:aid"
}
我希望我可以包含任何进一步的解释。
如何获取 on 方法中的最后一个路径参数。
@Path("{profile}/articles")
public getAllArticles(@PathParam("profile") String profile ){
}
@Path("{articleId}")
public getArticle(@PathParam("articleid") long id ){
}
I know how to get the recent path parameter like
articleId
in methodgetArticle
. but i want to get the previous path parameter in thegetArticle
method.ex: if the URL is
/{profile}/articles/{articleId}
. How would I get values of both{profile}
and{articleId}
in same method
PS:我知道如果我从 UriInfo
如果在 @Path
注释中指定,您可以获得多个 @PathParam
。
@Path("/{profile}/articles/{articleId: \d+}")
public Article readArticle(
@PathParam("profile") final String profile,
@PathParam("articleId") final long articleId) {
// "SELECT a FROM Article a WHERE a.profile=:profile AND a.id=:aid"
}
我希望我可以包含任何进一步的解释。