java - 如何在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'];
}
解决方案
您可以使用带有@QueryMap
注释的多个查询参数,而不是@Query
.
@QueryMap Map<String, String> queryParams
然后你可以在 php.ini 中访问它。
$_GET['shoulder'];
$_GET['chest'];
推荐阅读
- entity-framework - 具有指定外键列名的 TPT
- sql - JPA/Hibernate 重叠 PK 和 FK 列
- python - 用于生成 SVG 线框球体的 Python 脚本
- javascript - 将所有对象对放入一个数组(Javascript)
- tkinter - 如何在 Tkinter 中并排放置窗口和顶层?
- python - 动态张量的堆栈
- python - 循环 HTML 以解析字典,但返回重复值
- javascript - 在父组件中提交表单之前,如何确保 axios.post 在子组件中执行?
- swift - 启用对数据的访问并在两种不同类型的视图上显示该数据
- python - 如何从python中的列表中提取元素