首页 > 解决方案 > 如何在java中的GET查询中发送HashMap

问题描述

我是Android的初学者。我正在尝试使用 Retrofit 进行交流。我面临的问题如下。您正尝试向服务器发送多个查询,如下所示:其他查询运行良好,但哈希图无法正常传递。请帮我解决我遇到的问题。帮帮我!

安卓改造.java代码

 @GET("product_option.php")
    Call<ResponseBody> request_detail_category_product_information1(

            @Query("option") String filter_option,
            @Query("page") String page,
            @Query("fitme") String fitme,
            @Query("body_information") Map<String, String>HashMap

    );

php代码

    $option = $_GET['option'];
    $now_page = $_GET['page'];
    $fitme = $_GET['fitme'];
    $body_information = $_GET['body_information']; 

    if($body_information){

        $shoulder = $body_information['shoulder'];

        $chest =  $body_information['chest'];

        $waist = $body_information['waist'];

        $hip =  $body_information['hip'];

        $thigh =  $body_information['thigh'];
   }

标签: javaphpandroidhashmapretrofit

解决方案


您可以使用带有@QueryMap注释的多个查询参数,而不是@Query.

@QueryMap Map<String, String> queryParams

然后你可以在 php.ini 中访问它。

$_GET['shoulder'];
$_GET['chest'];

例子


推荐阅读