RESTful 网络服务为 POST 请求返回不支持的媒体类型

RESTful webservice returning Unsupported Media Type for POST requests

我一直在使用 Jersey 开发 RESTful 网络服务。我已经创建了我的第一个服务,现在我正在尝试发送请求。这是我的单一 POST 方法:

@POST
@Path("getQuote")
@Consumes(MediaType.WILDCARD )
@Produces(MediaType.APPLICATION_XML)
public Response getQuote(
        @FormParam("effectiveTime") String effectiveTime,
        @FormParam("responseType") String responseType,
        @FormParam("transform") String transform,
        @FormParam("data") String data,
        @FormParam("dataType") String dataType,
        @FormParam("source") String source) {

    String output = "";
    try {
        Map<String, String> formParams = new HashMap<String, String>();
        formParams.put("effectiveTime",effectiveTime);
        formParams.put("responseType",responseType);
        formParams.put("transform",transform);
        formParams.put("data",data);
        formParams.put("dataType",dataType);
        formParams.put("source",source);
        //do stuff
    } catch (Exception e) {
        System.out.println(e);
        output = "Error";
    }
    return Response.status(200).entity(output).build();
}

我有一个 HTML 测试表单可以用来发送数据,并使用 RequestBin 检查了内容类型是否正确。以下是请求中的一些 headers:

Host: requestb.in
Content-Length: 16176
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/5.0
Content-Type: application/x-www-form-urlencoded

我尝试了以下内容类型但没有成功:

@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@Consumes("application/x-www-form-urlencoded")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Consumes(MediaType.APPLICATION_XML)
@Consumes(MediaType.WILDCARD )
& unspecified (no @Consumes annotation) 

我不确定如何调试此请求。我也尝试使用 curl 来测试以下参数:

curl --data "effectiveTime=1o1o1&dataType=lolo&data=lololol&transform=&responseType=lolol" http://localhost:8080/services/ahrdi/getQuote

结果相同

也许尝试使用 curl

设置媒体类型 header
curl -i -H "Content-Type:application/x-www-form-urlencoded" --data "effectiveTime=1o1o1&dataType=lolo&data=lololol&transform=&responseType=lolol" http://localhost:8080/services/ahrdi/getQuote

eclipse 重新使用原始 war,没有任何改动,因为我在 运行 mvn compile war:war

之后没有刷新我的项目

我 运行 mvn clean,在项目浏览器中刷新了我的项目,运行 mvn compile war:war 我重新启动了服务器,现在请求被接受了。