【发布时间】:2019-10-02 14:20:47
【问题描述】:
我正在使用 Servlet 来处理请求和响应。
我已使用以下代码来 Servlet 使用 webservice 转租的请求:
JSONObject parans = new JSONObject();
parans.put("commandid", "Enamu7l");
System.out.println("parans = " + parans);
Client restClient = Client.create();
WebResource webResource = restClient.resource("URL");
ClientResponse resp = webResource.accept(MediaType.APPLICATION_JSON)
.post(ClientResponse.class, parans.toJSONString());
这是我接收数据的 servlet 代码。
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String commandid= request.getParameter("commandid");
System.out.println(commandid);
}
commandid 从 web 服务接收 null。
如何在 webservice 中获取 servlet 中的数据?
【问题讨论】: