我正在尝试通过命令行向我的 api 发出 curl get 请求。
curl http://localhost:8080/getList?id=100&mrp=50&discount=0
Run Code Online (Sandbox Code Playgroud)
但是当我在我的 api 中记录请求时,我得到:
&{GET /getList?id=100 HTTP/1.1 1 1 which means that only id is being sent through the request. I don't understand why it is happening.
Run Code Online (Sandbox Code Playgroud)
当您使用多个请求参数分隔的 curl 命令运行时&,unix 会将&as 符号视为在后台执行前一个命令。它后面的其他所有内容都被视为单独的命令。
发送请求时将 url 用引号括起来
curl "http://localhost:8080/getList?id=100&mrp=50&discount=0"
Run Code Online (Sandbox Code Playgroud)