[英]Calling RESTful Webservice with @RequestParam and @RequestBody together using Angular
如何編寫 Angular 服務方法參數來調用具有 @RequestBody 和 @RequestParam 簽名的restful webservice Spring MVC。
代碼:
@RequestMapping(value = "/getChargements", method = RequestMethod.POST)
@ResponseBody
public PlanificationEtSuiviChargementDto getChargements (@RequestBody CriteriaPlanificationDto criteriaPlanificationDto,
@RequestParam boolean historique) {
LOG.info("getChargements");
return demandeChargementService.getChargementCalendrier(criteriaPlanificationDto.getParams(),
criteriaPlanificationDto.getStep(), criteriaPlanificationDto.getPage(), historique);
}
角度服務方法:
public getPlanification(criteria: Criteria, step: number, page: number,historique: boolean): Observable<PlanificationData> {
return this.http.post(this.config.getIp() + 'chargements/getChargements.html/',
{ 'params': criteria, 'step': step, 'page': page },historique,
this.http.getJsonOptions()).pipe(map((rep: Response) => rep.json()));
}
如果你能幫助我,我將不勝感激。 祝你今天過得愉快!
@PutMapping("/{id}")
public Customer updateCustomerInfo(@PathVariable Long id,
@RequestBody Customer requestCustomer) {
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.