【问题标题】:Rest , send parameter with Get as query string or just use Post to get informationRest ,使用 Get 作为查询字符串发送参数或仅使用 Post 获取信息
【发布时间】:2017-06-15 23:09:41
【问题描述】:

我需要公开 Rest API,它基于 brandId 检索有关 Brand 的信息, 所以我需要发送brandId 参数。 从 Rest 架构和设计的角度来看,我应该使用 Post(在正文中带有参数),还是使用 Get 并将参数作为查询字符串或标题发送

【问题讨论】:

    标签: java rest architecture


    【解决方案1】:

    您应该使用 GET。 POST 用于将一些新信息放入或更新到服务/数据库中。

    尝试阅读:What is the difference between POST and GET?

    还有这个:When should I use GET or POST method? What's the difference between them?

    【讨论】:

      【解决方案2】:

      我使用GET,并将参数brandId作为路径变量发送

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2021-12-23
        • 2011-06-02
        • 2011-06-30
        • 1970-01-01
        • 1970-01-01
        • 2021-03-13
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多