[英]how to send object using postman rest client to call REST service so that it will hit the below given method with proper method parameters?
我正想從郵遞員那里調用休息發布方法。 但是我不能正確地為郵遞員設置方法的輸入參數。
注意:請不要將其標記為重復項,因為此對象在Stackoverflow中已有答案。
在其余API代碼下方:
@RequestMapping(value = "/city/village/home", method = RequestMethod.POST)
@ResponseBody
public String updateHome(@ModelAttribute final HomeAddress homeAddress,
final HttpServletRequest request) {
//// some code /////
}
This is the HomeAddress class
public class HomeAddress{
public String name;
public int id;
public List<String> membersName;
getters.....
setters....
}
請告訴我如何發送來自郵遞員的請求?
如果默認情況下使用Spring,則您的應用程序將在localhost:8080
>上運行,則可以使用/city/village/home
> localhost:8080/city/village/home
。 您可以看一下Spring Boot Controller的示例-https: //adityasridhar.com/posts/how-to-create-simple-rest-apis-with-springboot
我不確定您是否在類上使用@Controller
注釋,等等...您可以在此處查看如何使用郵遞員-> https://adityasridhar.com/posts/how-to-create-simple-rest-帶有springboot的api
您應該使用Json格式-您可以在這里進行驗證: https : //jsonformatter.curiousconcept.com/
{
"name": "NAme",
"id": 5,
"membersName": [
"firstName",
"secondName"
]
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.