0

how to write angular service method params to call a restful webservice Spring MVC having in its signature @RequestBody and @RequestParam together.

java code :

@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);
    }

Angular service method :

    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()));
    }

i will be grateful if you help me. have a nice day!

alma elghoul
  • 183
  • 1
  • 2
  • 12
  • you can add that requestparam variable as part of DTO object itself. so in your case historique should be part of criteriaPlanificationDto – Mandar Dharurkar Jan 15 '20 at 11:32

1 Answers1

0
 @PutMapping("/{id}")
        public Customer updateCustomerInfo(@PathVariable Long id, 
                                           @RequestBody Customer requestCustomer) {
Oleg Pavlyukov
  • 151
  • 1
  • 11