1

I have written a resource class with which I want to support multiple resource paths.

@Path("/path/to/jobs")
public class JobController {

    @GET
    @Produces(MediaType.APPLICATION_JSON)
    public List<JobDto> getJobs() {
        ...
    }

    @GET
    @Produces(MediaType.APPLICATION_JSON)
    @Path("{job_id}")
    public JobDto getJob() {
        ...
    }
}

The problem is that this accepts the path localhost:80/path/to/jobsbut not localhost:80/path/to/jobs/job123. I have tried annotating the class with /path/to and the methods with jobs and jobs/{job_id}. It still doesn't work. Any pointers?

I found this question and this which seem to suggest I should be able to do this.

Community
  • 1
  • 1
341008
  • 9,862
  • 11
  • 52
  • 84

1 Answers1

0

Now it accepts

localhost:80/path/to/jobsjob123

. If you want to get response with

localhost:80/path/to/jobs/job123

annotate the getJob() method with

@Path("/{job_id}")

You just missed the "/"

0x6B6F77616C74
  • 2,559
  • 7
  • 38
  • 65