Skip to content

gin学习记录-bind参数绑定 - Kjasn's World #6

@kjasn

Description

@kjasn

https://kjasn.github.io/2023/08/16/gin%E5%AD%A6%E4%B9%A0%E8%AE%B0%E5%BD%95-bind%E5%8F%82%E6%95%B0%E7%BB%91%E5%AE%9A/#4-5-bind-%E7%BB%91%E5%AE%9A%E5%99%A8

  1. bind 绑定参数gin 中的 bind 可以很方便的将前端传递来的数据与结构体进行参数绑定,以及参数校验 4.1 参数绑定在使用这个功能的时候,需要给结构体加上Tag :json,form,url 两种绑定方式: MustBind 实际开发不用,校验失败会改状态码 ShouldBind 可以绑定json, query, param, yaml, xml,如果校验不通过会返

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions