【问题标题】:Send parameter microservices. Jhipster 4.6.2发送参数微服务。 Jhipster 4.6.2
【发布时间】:2017-08-04 20:27:47
【问题描述】:

如果正确加载了值,我不会在 Angular 服务中从前到后获取我的参数: 如果 embarno 没有到达后端,同样的代码可以在 Jhipster 4.4.1 的垄断应用程序中正常工作。 现在还没迁移,在4.6.2版本的微服务中,不知道是不是改了发送参数的语法。

控制器:

  this.contactoService.byCliente(this.cliente.id).subscribe(
            result => { this.contactos = result; },
            error => { console.debug(error); });

服务:

byCliente(clienteId?: any): Observable<Contacto[]> {
    let params = new URLSearchParams();
    params.set('clienteId', clienteId);
    return this.http.get(this.resourceUrl + "/bycliente", { search: params }).map((res: Response) => {
        return res.json();
    });
}

返回(微服务):

 @GetMapping("/contactos/bycliente")
 @Timed
 public ResponseEntity<List<ContactoDTO>> getAllContactosByCliente(@RequestParam String clienteId) {
   log.debug("REST request to get a page of Contactos");
   List<ContactoDTO> list = contactoService.findContactosByCliente(clienteId);
   return new ResponseEntity<>(list, HttpStatus.OK);
 }

错误:

An unexpected error occurred: Required String parameter 'clienteId' is not present org.springframework.web.bind.MissingServletRequestParameterException: Required String parameter 'clienteId' is not present

【问题讨论】:

  • 我为隐私问题重命名了它,它已经修复了。
  • 没有足够的详细信息来获取帮助。浏览器发送的 HTTP 请求转储怎么样?

标签: angular jhipster


【解决方案1】:

在你的Service中调用api的时候尽量把参数直接放在url中:

byCliente(clienteId?: any): Observable<Contacto[]> {
    let params = new URLSearchParams();
    return this.http.get(this.resourceUrl + "/bycliente?clienteId="+clienteId).map((res: Response) => {
        return res.json();
    });
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-08-26
    • 2018-01-02
    • 2016-11-22
    • 1970-01-01
    • 2019-07-30
    • 2018-03-29
    • 2018-12-10
    • 1970-01-01
    相关资源
    最近更新 更多