解决方法:
在配置文件中添加:copyrequestbody = true
Controller:
// UserAdd @Title UserAdd
// @Description 新增事件
// @Param body body models.UserAdd true "添加用户"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"新增成功"}"
// @Failure 403 body is empty
// @router /add [post]
func (this *UserControlller) UserAdd() {var user models.UserAddvar err errorif err = json.Unmarshal(this.Ctx.Input.RequestBody, &user); err == nil {if ret, err := service.UserAdd(user); err == nil {this.Data["json"] = models.JsonData{200, "添加成功", ret}} else {this.Data["json"] = models.JsonData{500, "添加失败", 0}}} else {this.Data["json"] = models.JsonData{500, "json格式解析失败", 0}}this.ServeJSON()
}