Jersey @PathParam:包含多个没有注释的参数 [英] Jersey @PathParam : contains multiple parameters with no annotation
问题描述
以下是我在Jersey中使用的方法签名,当我调试/运行程序时,我得到以下错误:
The following is my method signature which I am using in Jersey , when I debug/run the program I am getting error as :
[[FATAL]方法public javax.ws.rs.core.Response com.xxxx.xxxxx.Xxxxx.xxxxx.xxxxxxxx(java.lang.String,java.lang.String,java.lang.String,javax.资源类com.xxxxxx.xxxxx.xxxxxx.xxxxxx上的ws.rs.container.ContainerRequestContext)包含多个没有注释的参数.
[[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.
我的代码:
@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) {
}
我在这里做错了.
谢谢
推荐答案
该答案帮助我解决了我的错误,但是正如CássioMazzochi Molin在下面的评论中所提到的:它不会为您提供帮助(并且该文档是错误的.版本的泽西岛..).我很想念.
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 :)
那里!
我对REST真的很陌生(因此,用一桶草药盐来回答我的问题), 但我想我知道您的错误来自哪里.
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.
您必须绑定您的参数rawData
.
示例:@PathParam("rawdata") String rawData
或
@HeaderParam("rawdata") String rawData
取决于要从何处提取参数,您必须 在参数上写一个@annotation.
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:
- 查询
- URI
- 路径
- 表格
- 饼干
- 标题
- 矩阵
- Query
- URI
- Path
- Form
- Cookie
- Header
- Matrix
以上文字摘自链接: http://docs.oracle.com/javaee/6/tutorial/doc /gilik.html 您应该 看看并阅读一些有关它的内容 :)
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 :)
这篇关于Jersey @PathParam:包含多个没有注释的参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!