Java 在邮递员中发送 PathVariable @PostMapping
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/53292263/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Send PathVariable @PostMapping in postman
提问by Dumidu Udayanga
I want send path variable in post mapping, in postman software.I select post mapping body and then how to do? I checked with @RequestParam vs @PathVariableexample,all answers for get method, But I need answer for post method.
我想在 post 映射中发送路径变量,在 postman 软件中。我选择了 post 映射正文,然后怎么办?我检查了@RequestParam vs @PathVariable示例,get 方法的所有答案,但我需要 post 方法的答案。
@RestController
@RequestMapping("api/v1/customers")
public class CustomerController {
@PostMapping("/{code}")
public String postRequest(@PathVariable String code,@RequestBody CustomerDTO dto){
System.out.println(dto);
System.out.println(code);
return "Something";
}
}
采纳答案by baba
回答by Mykhailo Moskura
You can refer official documentation :
你可以参考官方文档:
https://www.getpostman.com/docs/v6/postman/sending_api_requests/requests
https://www.getpostman.com/docs/v6/postman/sending_api_requests/requests
Please go to charpter URL .
请转至章节网址。
Some API endpoints use path variables. You can work with those in Postman. Below is an example of a URL with a path variable:
一些 API 端点使用路径变量。您可以与 Postman 中的人一起工作。下面是一个带有路径变量的 URL 示例:
https://api.library.com/:entity/
https://api.library.com/:entity/
To edit the path variable, click on Params to see it already entered as the key. Update the value as needed. For example, :entity can be “user” in this specific case. Postman also gives you suggestions to autocomplete the URL.
要编辑路径变量,请单击 Params 以查看它已作为键输入。根据需要更新值。例如,在这种特定情况下,:entity 可以是“user”。Postman 还会为您提供自动完成 URL 的建议。
回答by szyjek
the easy way to put a path variable in Postman is your case is "/:code"
在邮递员中放置路径变量的简单方法是您的情况是“/:code”