简体   繁体   中英

Calling RESTful Webservice with @RequestParam and @RequestBody together using Angular

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!

 @PutMapping("/{id}")
        public Customer updateCustomerInfo(@PathVariable Long id, 
                                           @RequestBody Customer requestCustomer) {

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM