Reputation: 1114
How would i get the last path parameter in on method.
@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: I know i can get that by breaking the URL,if I get path from UriInfo
Upvotes: 0
Views: 231
Reputation: 22027
You can get multiple @PathParam
if you specified in the @Path
annotation.
@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"
}
I wish I can include any further explanation.
Upvotes: 1