Does Jersey support the dollar sign in the JAX-RS path annotation?

I would like to have access to the following holiday urls:

The first url works fine. I am having problems with the $ count URL using JAX-RS Jersey.

Here is the resource code.

@Path("/helloworld")
public class HelloWorldResource {
    @GET
    @Produces("text/plain")
    public String getClichedMessage() {
        return "Hello World!";
    }

    @GET
    @Path("\\$count")
    @Produces("text/plain")
    public String getClichedMessage(
            @PathParam("\\$count") String count) {

        return "Hello count";
    }
}

I also tried to "count the number" in both @Path and @PathParam, but that didn't work either.

Note. If I remove the dollar sign from all of the above code, it works fine for the localhost url: 9998 / helloworld / count. However, I need a dollar sign that will be there in the url because it will be an OData maker application.

+5
source share
3 answers

. .

@GET
@Path("{count : [$]count(/)?}")
@Produces("text/plain")
public String getClichedMessageCount(
        @PathParam("count") String count) {

    return "Hello count";
}

URL-.

  • : 9998/HelloWorld/$
  • : 9998/HelloWorld/$/
  • : 9998/HelloWorld/$ $ =
  • : 9998/HelloWorld/$/ $ =
+3
+1

@Path

@GET
@Path("/$count")
@Produces("text/plain")
public String getClichedMessage(
        @PathParam("\\$count") String count) {

    return "Hello count";
}

PathParam. /helloworld,

@GET
@Path("/{$count}")
@Produces("text/plain")
public String getClichedMessage(
        @PathParam("$count") String count) {

    return "Hello count";
}

  $

@Path("count") // works
@Path("/count") // works
@Path("\\count") // does not work
@Path("$count") // does not work
@Path("/$count") // does not work
0
source

All Articles