beego 获取POST Payload 参数

  1. 在配置文件中 copyrequestbody = true
  2. type user struct {
    	Username string `form:"username"`
    	Password string `form:"password"`
    }
    
    func (this *LoginController) Login() {
    	u := new(user)
    	json.Unmarshal(this.Ctx.Input.RequestBody, &u)
    	this.Ctx.WriteString(u.Username + "--" + u.Password)
    }
    

      示例:

            

 

            

 

          

 

 

 

 

posted @ 2022-05-03 22:24  php的自我修养  阅读(212)  评论(0编辑  收藏  举报