gpt4 book ai didi

java - 缺少服务器异常 Spring Boot

转载 作者:行者123 更新时间:2023-11-29 04:17:14 24 4
gpt4 key购买 nike

我在 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 用于 path 变量:

 public List filterResult(@PathVariable("paramSelect") String  paramSelect , @PathVariable("dateStart") String dateStart , @PathVariable("dateEnd") String dateEnd) {

关于java - 缺少服务器异常 Spring Boot,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51588285/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com