使用POST的Restful Web服务

时间:2012-02-07 15:48:10

标签: web-services rest post

我正在尝试编写一个使用POST方法的rest webservice。我正在使用Firefox的海报插件来测试服务。但是我对如何检索我在请求中发送的内容毫无头绪。类似于GET中的queryparam,有人可以告诉我如何在POST中获取params

 @Path("/ldap")
       public class Ldap {
String xml = "";
static String ATTRIBUTE_FOR_USER = "sAMAccountName";

@POST
@Path("/xml")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public String geterrorxml(@PathParam ("username")@DefaultValue("tess") String                      username,@PathParam ("password")@DefaultValue("passw3") String password) throws Exception {
    MYpojo mYpojo = new MYpojo();

    String xml_output = "";
     System.out.println(username);
      System.out.println(password);
                return null;

}
    }

1 个答案:

答案 0 :(得分:0)

使用@FormParam并使用与param相同的名称命名您的输入

<input type="text" name="username" />

public String geterrorxml(@FormParam ("username") @DefaultValue("tess") String username)[..]