我正在尝试使用多辆汽车在Spring Boot中调用服务器
从客户端,我发送URL 2字符串和发送我发送数组
const url: string = "http://localhost:8090/duplicateSession/" + currentExec + "/" + this.year;
response = this.http.post<MyMessage>(url, arrayMonths, { responseType: 'json' });
现在我正试着这个 - >
@RequestMapping(method = RequestMethod.POST, value = "/duplicateSession/{periodExec}/{periodYear}", produces = MediaType.APPLICATION_JSON_VALUE)
public MyMessage duplicateSession(@RequestBody ArrayList<Integer> listPeriod, @PathVariable ("periodExec") String periodExec, @PathVariable ("periodYear") String periodYear) {
System.out.println("hellooooo");
}
我试过 - >
const url: string = "http://localhost:8090/cm/duplicateSession?periodExec=" + currentExec + "&periodYear=" + this.year;
我没有错误,我没有在客户端找到错误,我没有在我的SpringBoot中发现错误。
如果使用格式?a=A&b=B
,则将参数传递给url。相反,您的网址被指定为/duplicateSession/{periodExec}/{periodYear}
,它期待路径变量。
需要订阅http req才能触发事件。
response = this.http.post<MyMessage>(url, arrayMonths, { responseType: 'json' });
response.subscribe((items) => console.log(items))