V
V
Vladimir Prikhodko2014-09-22 19:11:02
Java
Vladimir Prikhodko, 2014-09-22 19:11:02

Java REST. How to write a path like /get/group1/group2/... in Path?

Good afternoon.
I need to write in @Path something like /get/group1/group2/...... and so on. That is, I do not know the number of groups.
Here, with this writing, everything that is after get/ is read into id. And I want to accept id as a List

@GET
@Path(value = "get/{id : .+}/")
@Produces(MediaType.APPLICATION_JSON)
.....

Tell me how to do it right

Answer the question

In order to leave comments, you need to log in

2 answer(s)
F
FanKiLL, 2014-09-22
@FanKiLL

And why are you doing this through Get, make a request for groups or whatever you want to give through the post. For example, on the url - /get/groups they send you a list of groups in json and you will take them from there. So the mapping will be cleaner.

B
bromzh, 2014-09-22
@bromzh

As an option, read the entire tail into a string variable, split it along the slash, and at the output you will just get a List. Something like here and here .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question