我检查了与此相关的线程,但没有人帮助我。我是 spring 的新手,当我尝试按参数发送请求值时出现此错误。
@RequestMapping(value="/receipt", params = "id", method=RequestMethod.GET)
public String index(@PathVariable String id, ModelMap model){
return "receipt"
}
现在,当我尝试使用 url: localhost:8080/url/receipt?id=10 访问该 url 时,出现该错误。
最佳答案
您将 id 声明为 PathVariable,但将其作为 RequestParamter 传递。
如果您想使用 url: localhost:8080/url/receipt?id=10 访问您的函数,您应该将您的函数更改为:
@RequestMapping(value="/receipt", method=RequestMethod.GET)
public String index(@RequestParam(value = "id", required = true) String id){
return "receipt";
}
关于java - spring mvc - 客户端发送的请求在语法上不正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15727488/