原来的代码

@PostMapping("/wx/hdrlist/{hdrWxOpenid}/{hdrStatus}")
@ResponseBody
public AjaxResult selectByOpenidAndStatus(@PathVariable("hdrWxOpenid") String openid, @PathVariable("hdrStatus") String status) {
    List<ScHdr> hdrs = scHdrService.selectByOpenidAndStatus(openid, status);
    return AjaxResult.success(hdrs);
}

错误原因与解决方案

前端向后端发送POST请求且携带参数为JSON类型时,后端不能简单地使用@RequestParam接收数据
应该使用@RequestBody、制作一个Map来接收参数

修改后的代码

@PostMapping("/wx/hdrlist")
@ResponseBody
public AjaxResult selectByOpenidAndStatus(@RequestBody Map<String, String> params) {
    List<ScHdr> hdrs = scHdrService.selectByOpenidAndStatus(params.get("openid"), params.get("status"));
    return AjaxResult.success(hdrs);
}
Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐