代码之家  ›  专栏  ›  技术社区  ›  shabz

当类对象可以在方法的参数中传递时,为什么要使用@Body注释?

  •  0
  • shabz  · 技术社区  · 8 年前

    在getLocation()方法中,如果只传递TableParameter对象,会有什么不同?

        public interface MasterAPI {
        @POST("Master/getLocation")
        public Call<List<LocationGetTab>> getLocation(@Body TableParameter 
        parameter);
        }
    

    Class TableParameter定义如下:

        public class TableParameter {
        @SerializedName("State")
        int State;
        @SerializedName("district")
        int District;
        @SerializedName("LocType")
        String locType;
    
        public TableParameter(int district, int state, String locType) {
        District = district;
        State = state;
        this.locType = locType;
        }
        }
    
    1 回复  |  直到 8 年前
        1
  •  0
  •   Jyubin Patel    8 年前

    @当您将对象作为参数传递,将所有定义到模型类中的参数作为请求参数传递给服务时,将使用主体注释。

    请阅读整个改装文档,它对您有很大帮助。

    希望你能理解。