简体   繁体   中英

spring mvc - The request sent by the client was syntactically incorrect

I checked the threads concerning this and none is helping me. I am new to spring and I get this error when I try to send request values by parameter.

@RequestMapping(value="/receipt", params = "id", method=RequestMethod.GET)
public String index(@PathVariable String id, ModelMap model){
    return "receipt"
}

Now when I try to access the url using the url: localhost:8080/url/receipt?id=10, i get that error.

You declare id as PathVariable, but you pass it as a RequestParamter.

If you want to access your function with url: localhost:8080/url/receipt?id=10, you should change you function to:

@RequestMapping(value="/receipt",  method=RequestMethod.GET)
public String index(@RequestParam(value = "id", required = true) String id){
    return "receipt";
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM