Java RESTEasy在@DELETE方法中以表单参数形式提供空值

Java RESTEasy在@DELETE方法中以表单参数形式提供空值,java,rest,resteasy,Java,Rest,Resteasy,我正在使用REASTEasy设计restfulweb服务API。我有一个工作流,其中我必须删除资源中的多个项目。web服务签名如下所示 @DELETE @Consumes(MediaType.APPLICATION_FORM_URLENCODED) @Produces(MediaType.APPLICATION_JSON) @Path("/directories/{directoryname}/documents") public Response deleteDocuments(@FormPa

我正在使用REASTEasy设计restfulweb服务API。我有一个工作流,其中我必须删除资源中的多个项目。web服务签名如下所示

@DELETE
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@Produces(MediaType.APPLICATION_JSON)
@Path("/directories/{directoryname}/documents")
public Response deleteDocuments(@FormParam("documentnames")final String documents, @PathParam("directoryname")final String directoryName)
我提出以下要求

DELETE /directories/1234/documents HTTP/1.1
Host: localhost:8080
Cache-Control: no-cache
Postman-Token: 45c0094f-1853-5710-2201-a1102a6acef0
Content-Type: application/x-www-form-urlencoded

documentnames=test

但是,当调用该方法时,表单参数“documentnames”的值为
null
,即使我将其值传递为
test
,如请求中所示

再次查看您的注释:

@Path("/directories/{directoryname}/documents")
public Response deleteDocuments(@FormParam("documentnames")final String documents, @PathParam("directoryname")final String directoryName)
@PathParam(“directoryname”)
指的是
@Path
定义中的
{directoryname}
,而
@FormParam(“documentnames”)
应该从表单请求中获取数据。但是,您可以在没有表单参数的情况下执行
httpdelete
。至少我没有在你们送来的俘虏中看到他们


您可能也希望将目录作为路径参数发送吗?

表单参数在请求的末尾显示为
documentnames=test
。哦,对不起,我没有看到它。我认为(几乎可以肯定)delete方法根本不支持body。看看这篇文章:。它建议添加这样的功能来删除和放置方法。因此,您应该仅将URL路径参数用于删除。