如果在以下位置正确加载了值,我不会在Angular Service中从前到后获取我的参数: 如果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
答案 0 :(得分:1)
Try to put the parameter directly in the url when calling the api in your Service :
byCliente(clienteId?: any): Observable<Contacto[]> {
let params = new URLSearchParams();
return this.http.get(this.resourceUrl + "/bycliente?clienteId="+clienteId).map((res: Response) => {
return res.json();
});
}