我正在尝试编写一个使用POST方法的rest webservice。我正在使用Firefox的poster插件来测试该服务。但是,我对如何检索我在请求中发送的内容一无所知。类似于GET中的queryparam,谁能告诉我如何在POST中获取参数
@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;
}
}
发布于 2012-02-07 23:49:46
使用@FormParam并使用与参数相同的名称命名输入等
<input type="text" name="username" />
public String geterrorxml(@FormParam ("username") @DefaultValue("tess") String username)[..]
https://stackoverflow.com/questions/9179298
复制相似问题