Jersey @PathParam : contains multiple parameters with no annotation

放肆的年华 提交于 2019-12-11 07:59:53

问题


The following is my method signature which I am using in Jersey , when I debug/run the program I am getting error as :

[[FATAL] Method public javax.ws.rs.core.Response com.xxxx.xxxxx.Xxxxx.xxxxx.xxxxxxxx(java.lang.String,java.lang.String,java.lang.String,javax.ws.rs.container.ContainerRequestContext) on resource class com.xxxxxx.xxxxx.xxxxxx.xxxxxx contains multiple parameters with no annotation.

My code:

@PUT
@Path("/user/{user}/{role}")
@Consumes({MediaType.APPLICATION_JSON,MediaType.TEXT_PLAIN})
@Produces("application/json")

public Response myFunction(@PathParam("user") String user,
    @PathParam("role") String role,
    String rawData,
    @Context ContainerRequestContext crc) {

}

What I am doing wrong here.

Thank you


回答1:


Edit: This answer helped me solve my error, but as Cássio Mazzochi Molin mentioned in the comment below: it wont help you (and the documentation is for the wrong version of Jersey..). A total miss on my part.

Please excuse my attempt to help you. I hope you already have solved your error :)

Ahoy there!

I'm really new to REST (so take my answer with a bucket of herb salt), but I think I know where your error is coming from.

You have to bind your parameter rawData.

Example: @PathParam("rawdata") String rawData or @HeaderParam("rawdata") String rawData

Depending on where you want to extract the parameter from you have to write a @annotation to the parameter.

You can extract the following types of parameters for use in your resource class:

  • Query
  • URI
  • Path
  • Form
  • Cookie
  • Header
  • Matrix

Text above is taken from the link: http://docs.oracle.com/javaee/6/tutorial/doc/gilik.html You should take a look and read a little about it if you haven't done it already :)



来源:https://stackoverflow.com/questions/39264786/jersey-pathparam-contains-multiple-parameters-with-no-annotation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!