本例场景:使用Postman工具访问http://localhost:8080/user/insert对应后台方法是如下代码

@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserMapper userMapper;

    @PostMapping("/insert")
    public int insert(@RequestBody User user) {
        return userMapper.insert(user);
    }
}

解析:在后台方法参数上添加@RequestBody时,将请求参数封装成User对象时,需要JSON(application/json)格式解决:在Postman中如下设置即可正常访问,便于调试。解决:Required request body is missing-LMLPHP

12-02 14:10