简体   繁体   English

当 curl 命令发送 http 请求时,获取 java 中的数据

[英]Get data in java when http request sent by curl command

Does anyone know how to get data in java when http request sent by curl command "--data"?当 curl 命令“--data”发送 http 请求时,有谁知道如何在 java 中获取数据? For example:例如:

curl --data { Name : username , Gender : gender , Age : age } -X PUT http://localhost:8080/user/folder -v

I want to know how to get data { Name:username,..... age } using curl command --data.我想知道如何使用 curl 命令 --data 获取数据{ Name:username,..... age } I use the method in REST Web service which is used jersey framework and java.我使用了 REST Web 服务中的方法,该服务使用了 jersey 框架和 Z93F725A074238B333FE1C8186ZD24。

Since you PUT data when you use curl this way, all you need to do is to implement a PUT request handler.由于您在以这种方式使用 curl 时 PUT 数据,因此您需要做的就是实现 PUT 请求处理程序。 In theory at least:)至少在理论上:)

Something like就像是

@PUT
@Path("/user/folder")      
@Consumes("application/json")
public void receiveData(String data) { 
    ......
}

edit: didn't see the -X PUT at first.编辑:起初没有看到 -X PUT 。 you want a PUT handler not a POST handler.你想要一个 PUT 处理程序而不是 POST 处理程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM