dom*_*ino 5 java web-services cxf jax-rs
如何在POST请求中的请求正文中发送多个参数?
@POST
@Consumes("multipart/form-data")
@Produces("application/json")
public String addForm1(@FormParam("i1") Integer i1, @FormParam("i2") Integer i2);
Run Code Online (Sandbox Code Playgroud)
上面的代码返回HTTP 415.
@FormParam用错误替换@Multipart结果Resource method has more than one parameter representing a request body,如下所示.
SEVERE: Resource method service.rs.TestService.postData2 has more than one parameter representing a request body
Exception in thread "main" org.apache.cxf.jaxrs.client.ClientWebApplicationException: Resource method service.rs.TestService.postData2 has more than one parameter representing a request body
at org.apache.cxf.jaxrs.client.ClientProxyImpl.reportInvalidResourceMethod(ClientProxyImpl.java:546)
at org.apache.cxf.jaxrs.client.ClientProxyImpl.getParametersInfo(ClientProxyImpl.java:214)
at org.apache.cxf.jaxrs.client.ClientProxyImpl.invoke(ClientProxyImpl.java:138)
at $Proxy20.postData2(Unknown Source)
at service.TestServiceClient.main(TestServiceClient.java:82)
Run Code Online (Sandbox Code Playgroud)
另外,为了传递多种复杂类型,例如List<Map<String, String>>' or 'List<MyNestedCustomObject>在POST方法中,我需要做什么?我可以通过使用JAXB和注释来传递这样的参数@XmlJavaTypeAdapter,但我想这在传递多个参数的情况下不起作用?我是否需要定义自己的消息体读者和作者?任何示例代码都很有用.
谢谢
| 归档时间: |
|
| 查看次数: |
13668 次 |
| 最近记录: |