相关疑难解决方法(0)

将json发布到spring mvc控制器

控制器签名(我也尝试过请求者):

@RequestMapping(value = "/Lame", method = RequestMethod.POST)
public
@ResponseBody
boolean getLame(@RequestParam String strToMatchA, @RequestParam String strToMatchB) {}
Run Code Online (Sandbox Code Playgroud)

这就是我的json:

{
"strToMatchA": "EN",
 "strToMatchB": "lon"
}
Run Code Online (Sandbox Code Playgroud)

不工作,我收到错误:

org.springframework.web.bind.MissingServletRequestParameterException: Required String parameter 'strToMatchA' is not present
Run Code Online (Sandbox Code Playgroud)

从方法签名中删除第一个参数然后使其工作(方法被正确调用),我该怎么办?

当我更改要注释的方法参数时,@RequestBody我得到以下错误:

java.io.IOException: Stream closed
Run Code Online (Sandbox Code Playgroud)

javascript java spring json spring-mvc

5
推荐指数
1
解决办法
7021
查看次数

标签 统计

java ×1

javascript ×1

json ×1

spring ×1

spring-mvc ×1