我想使用泽西库建立一个RESTfull API,但它给了我一个例外。 这里是我的文档类不支持的媒体类型球衣RESTfull api
@XmlRootElement
@XmlAccessorType(XmlAccessType.PUBLIC_MEMBER)
public class Docs {
@XmlElement(name = "field")
public String field;
@XmlValue
public String content;
}
@Path("/update")
public class Update {
@POST
@Path("/xml")
@Consumes(MediaType.APPLICATION_XML)
@Produces(MediaType.APPLICATION_XML)
public String createIndexXML(Docs docs)
throws Exception {
System.out.println(docs.content);
return "It works";
}
}
如果我尝试使用curl它抛出Error 415 Unsupported Media Type
curl -XPOST "http://localhost:8089/update/xml" -d '<docs>
<field>title</field>
</docs>'
我试过curl -H“Content-Type:text/xml”-X POST“http:// localhost:8089/update/xml”但我仍然遇到同样的问题 – Kathick 2013-02-27 05:47:38