我在将 json contentType 传递到 glassfish 服务器时遇到问题,我在该服务器上设置了 java RESTful Web 服务。
我用针从 Node.js 发布:
var options = {
json: true,
headers: {'Content-Type':'application/json'}
}
needle.post(base_url+'priorityList/',priorityList,options, function(err, resp, body){
});
并收到球衣:
@POST
@Path("/priorityList/")
@Consumes(MediaType.APPLICATION_JSON)
//@Consumes("text/plain")
@Produces(MediaType.APPLICATION_JSON)
public JSONArray priorityList(JSONObject incomingJsonString)throws IOException {
}
它在 glassfish 服务器上给了我这个错误:
WARNING: StandardWrapperValve[com.mycompany.recommenderenginejava.ApplicationConfig]: Servlet.service() for servlet com.mycompany.recommenderenginejava.ApplicationConfig threw exception
org.codehaus.jackson.map.exc.Unr`enter code here`ecognizedPropertyException: Unrecognized field "{"categories":["golf","banks"]}" (Class com.mycompany.recommenderenginejava.JSONObject), not marked as ignorable
at [Source: org.glassfish.jersey.message.internal.EntityInputStream@4c0db744; line: 1, column: 43] (through reference chain: com.mycompany.recommenderenginejava.JSONObject["{"categories":["golf","banks"]}"])
at org.codehaus.jackson.map.exc.UnrecognizedPropertyException.from(UnrecognizedPropertyException.java:53)
at org.codehaus.jackson.map.deser.StdDeserializationContext.unknownFieldException(StdDeserializationContext.java:267)
at org.codehaus.jackson.map.deser.std.StdDeserializer.reportUnknownProperty(StdDeserializer.java:673)
这看起来应该是正确的格式,我有点理解,并且已经尝试了 1000 种方法来让它工作。
任何帮助是极大的赞赏