Controller signature (I have tried as requestbody as well) :
控制器签名(我也尝试过请求者):
@RequestMapping(value = "/Lame", method = RequestMethod.POST)
public
@ResponseBody
boolean getLame(@RequestParam String strToMatchA, @RequestParam String strToMatchB) {}
And this as my json :
这是我的json:
{
"strToMatchA": "EN",
"strToMatchB": "lon"
}
Not working, I receive the error :
不工作,我收到错误:
org.springframework.web.bind.MissingServletRequestParameterException: Required String parameter 'strToMatchA' is not present
Removing this first parameter from method signature then makes it work (the method gets called correctly), what should I be doing ?
从方法签名中删除第一个参数然后使其工作(方法被正确调用),我该怎么办?
When I change method parameters to be annotated with @RequestBody
I get the following error :
当我更改要使用@RequestBody注释的方法参数时,我收到以下错误:
java.io.IOException: Stream closed
1 个解决方案
#1
4
Your json is fine but not the controller signature. Create a class with setters matching the json. Use it as argument instead of your strings. Annotate it with requestbody. It should work.
你的json很好但不是控制器签名。使用与json匹配的setter创建一个类。使用它作为参数而不是字符串。用requestbody注释它。它应该工作。
#1
4
Your json is fine but not the controller signature. Create a class with setters matching the json. Use it as argument instead of your strings. Annotate it with requestbody. It should work.
你的json很好但不是控制器签名。使用与json匹配的setter创建一个类。使用它作为参数而不是字符串。用requestbody注释它。它应该工作。