Retrofit2 Get请求包含特殊字符

如果 Retrofit2 Get请求包含特殊字符(例如:%*?等),不希望请求的过程中被转码,可以使用参数(encoded = true):

1、接口定义:

    /**
     * 数据查询
     *
     * @return
     */
    @GET("ezview/vehicle/gather")
    Call> getVehicleList(@QueryMap(encoded = true) Map map);

2、接口调用:

 public void getQueryResult(String startTime, String stopTime, boolean loadMore) {
        Map map = new HashMap<>();

        if (startTime != null && startTime.length() > 0) {
            map.put("startTime", startTime + " 00:00:00");
        }

        if (stopTime != null && stopTime.length() > 0) {
            map.put("stopTime", stopTime + " 23:59:59");
        }
        if (loadMore) {
            pageNo++;
        } else {
            pageNo = 0;
        }

        map.put("pageNo", pageNo);
        map.put("pageSize", BundleConstants.pageSize);
        map.put("queryAll", false);//仅显示当前用户的信息

        serviceApi.getVehicleList(map).enqueue(new HttpRequestCallback() {
            @Override
            public void onSuccess(QueryResponse result) {
                super.onSuccess(result);
            }

            @Override
            public void onFailure(int status, String message) {
                super.onFailure(status, message);
            }
        });
    }

你可能感兴趣的:(Retrofit2)