我在Spring Boot中遇到错误,它说我不发送paramSelect
,但它是错误的,我发送了paramSelect。
我寄
public filterResult(paramSelect: string, filterDateStart: string, filterDateEnd: string): Observable<any> {
filterDateStart = filterDateStart.replace(/\//g, '-');
filterDateEnd = filterDateEnd.replace(/\//g, '-');
const url = 'http://localhost:8080/filterResult/' + paramSelect + '/' + filterDateStart + '/' + filterDateEnd;
return this.http.get<any>(url);
HTML错误->
zone.js:2969 GET http://localhost:8080/filterResult/EDU/04-07-2018/05-07-2018 400 ()
在我的SpringBoot中->
@RequestMapping(method = RequestMethod.GET, value = "/filterResult/{paramSelect}/{dateStart}/{dateEnd}", produces = MediaType.APPLICATION_JSON_VALUE)
public List filterResult(@RequestParam("paramSelect") String paramSelect , @RequestParam("dateStart") String dateStart , @RequestParam("dateEnd") String dateEnd) {
System.out.println("llego");
List<Parameter> list = pgService.filterResult(paramSelect, dateStart, dateEnd);
return list;
}
我收到一个错误:
Resolved exception caused by Handler execution: org.springframework.web.bind.MissingServletRequestParameterException: Required String parameter 'paramSelect' is not present
最佳答案
您应该更改为路径变量使用@PathVariable而不是@RequestParam
:
public List filterResult(@PathVariable("paramSelect") String paramSelect , @PathVariable("dateStart") String dateStart , @PathVariable("dateEnd") String dateEnd) {