【发布时间】:2020-05-02 02:55:38
【问题描述】:
如何编写 Angular 服务方法参数来调用在其签名中同时具有 @RequestBody 和 @RequestParam 的宁静 Web 服务 Spring MVC。
java代码:
@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 服务方法:
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()));
}
如果你能帮助我,我将不胜感激。 祝你有美好的一天!
【问题讨论】:
-
您可以将该 requestparam 变量添加为 DTO 对象本身的一部分。所以在你的情况下 historique 应该是 criteriaPlanificationDto 的一部分
标签: angular spring spring-mvc angular-fullstack