How can I overload a method with @QueryParam in Jersey/Spring?

java, jersey, overloading, query-string, spring

Solution

No can be.

It's ok in java, but the thing about it is - from the servlet side - jersey needs to map each url to some function in your class.

What you can do is, of course, separate it into 2 methods, or build one method that checks the parameters and does the right logic.

Problem

I would like to overload a method with the @QueryParam but everytime I try to execute this code it throws: ``` SEVERE: Exception occurred when intialization com.sun.jersey.spi.inject.Errors$ErrorMessagesException ``` My code is: ``` @GET @Path("/test") @Produces("text/plain") public String getText(@QueryParam("PID") String pid) { return pid; } @GET @Path("/test") @Produces("text/plain") public String getText(@QueryParam("PID") String pid, @QueryParam("NAME") String name) { return pid + name; } ```

Original source