JonSkeet 2013-07-19 05:25 采纳率: 0%
浏览 18802

使用http post如何传递多参数到restful web服务?

我创建了俩个数组参数和Objects数组,我想传递它们,我可以用下面的方法吗?

 @POST
 @Path("Test3")
 @Produces("text/plain")
 @Consumes({"application/json"})
  public String Test3(String[] id1,String[] id2 ,Object [] oo) {
        String result = "Hello ";

       ....
       ....
        return result;
    }

我要传递到这个方法里相应的 json 是什么?
我使用了很多的jsons,总是获得下面的错误:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>GlassFish Server Open Source Edition  4.0  - Error report</title><style type="text/css"><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 500 - Internal Server Error</h1><hr/><p><b>type</b> Exception report</p><p><b>message</b>Internal Server Error</p><p><b>description</b>The server encountered an internal error that prevented it from fulfilling this request.</p><p><b>exception</b> <pre>javax.servlet.ServletException: Servlet.init&#40;&#41; for servlet entities.service.ApplicationConfig threw exception</pre></p><p><b>root cause</b> <pre>org.glassfish.jersey.server.model.ModelValidationException: Validation of the application resource model has failed during application initialization.
[[FATAL] Method public java.lang.String entities.service.ItemFacadeREST.Test3&#40;java.lang.String,java.lang.String&#41; on resource class entities.service.ItemFacadeREST contains multiple parameters with no annotation. Unable to resolve the injection source.&#59; source=&#39;ResourceMethod{httpMethod=POST, consumedTypes=[application/json], producedTypes=[text/plain], suspended=false, suspendTimeout=0, suspendTimeoutUnit=MILLISECONDS, invocable=Invocable{handler=MethodHandler{handlerClass=class entities.service.ItemFacadeREST, handlerConstructors=[org.glassfish.jersey.server.model.HandlerConstructor@cdf30b]}, handlingMethod=public java.lang.String entities.service.ItemFacadeREST.Test3&#40;java.lang.String,java.lang.String&#41;, parameters=[Parameter [type=class java.lang.String, source=null, defaultValue=null], Parameter [type=class java.lang.String, source=null, defaultValue=null]], responseType=class java.lang.String}, nameBindings=[]}&#39;]</pre></p><p><b>note</b> <u>The full stack traces of the exception and its root causes are available in the GlassFish Server Open Source Edition  4.0  logs.</u></p><hr/><h3>GlassFish Server Open Source Edition  4.0 </h3></body></html>

对于http post我想从android中调用。

  • 写回答

3条回答 默认 最新

  • JaveZh 2013-07-19 06:03
    关注

    用BasicNameValuePair设置成Enity进行post

    评论

报告相同问题?

悬赏问题

  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题