我从AJAX调用这个REST API,但不知道怎么不能将JSON对象传递给@Path(“/ putEmp”)?

时间:2016-09-08 11:35:09

标签: json ajax rest

JSON以GET或PUT方式传递给Java中的REST API,除了以下内容之外我还应该拥有哪些库?

  1. bson-3.0.1.jar

    1. jackson-annotations-2.3.2.jar
    2. jackson-core-2.3.2.jar
  2. 杰克逊 - 数据绑定-2.3.2.jar 杰克逊 - JAXRS碱基2.3.2.jar        杰克逊 - JAXRS-JSON-提供商-2.3.2.jar

    杰克逊模块-JAXB的注解-2.3.2.jar jersey-entity-filtering-2.17.jar jersey-media-json-jackson-2.17.jar JSON-LIB-2,2,2- jdk15.jar

  3. 当我访问此REST服务时,我仍然收到以下错误:

    EROOR:没有为类org.json.JSONObject找到序列化程序,也没有发现创建BeanSerializer的属性(为了避免异常,请禁用SerializationFeature.FAIL_ON_EMPTY_BEANS))

        @GET
        @Path("/getJSON2/{a}/{b}/{c}")
        @Produces(MediaType.APPLICATION_JSON)
        public JSONObject getJSON2(@PathParam ("a") int a, @PathParam ("b") String b, @PathParam ("c") String c) throws JSONException
        {
        JSONObject js = new JSONObject();
        Employee ee = new Employee();
        ee.setId(a);
        ee.setFname(b);
        ee.setLName(c);
        System.out.println("==========="+ee.toString());
        js.put("employee", ee);
        return js;
    }
    

0 个答案:

没有答案