如何将 JSON 对象从 POSTMAN 发送到 Restful Webservices
2022-09-02 11:28:10
我正在尝试将json从POSTMAN发送到RESTful Webservice。我按照本教程的网址通过POSTMAN发送json。
我的网址 :
http://localhost:8080/myWebService/rest/dataInsert/insert
我的服务方法:
@POST
@Path("/insert")
@Consumes(MediaType.APPLICATION_JSON)
public String insertData(JSONObject jsonlist) throws UnknownHostException;
我的Impl:
@Override
public String insertData(JSONObject jsonlist) throws UnknownHostException {
System.out.println(jsonlist);
insertDataDao.insertData(jsonlist);
return "SUCCESS";
}
我的道:
public String insertData(JSONObject jsonlist) throws UnknownHostException{
System.out.println(jsonlist);
MongoConnection mongoconnection = new MongoConnection();
MongoClient mongoclient = mongoconnection.getMongoClient();
MongoDatabase db = mongoclient.getDatabase("mydb");
MongoCollection<Document> col = db.getCollection("col");
String jsonString = jsonlist.toString();
System.out.println(jsonString);
Document doc = Document.parse(jsonString);
col.insertOne(doc);
System.out.println("Inserted Successfully !!!");
return "SUCCESS";
}
但我面对的是以下异常:
JBWEB000236: Servlet.service() for servlet CXFServlet threw exception: java.lang.NoSuchMethodError: javax.ws.rs.InternalServerErrorException.validate(Ljavax/ws/rs/core/Response;Ljavax/ws/rs/core/Response$Status;)Ljavax/ws/rs/core/Response;
我无法解决此问题。任何人都可以帮我解决这个问题...