litesuits / android-lite-http

LiteHttp is a simple, intelligent and flexible HTTP framework for Android. With LiteHttp you can make HTTP request with only one line of code! It could convert a java model to the parameter and rander the response JSON as a java model intelligently.
http://litesuits.com?form=ghttp
Apache License 2.0
830 stars 347 forks source link

通过HttpParamModel接口无法传参? #12

Closed bf3400 closed 8 years ago

bf3400 commented 9 years ago

参考: https://zybuluo.com/liter/note/187568 (1. 简单参数 HttpParamModel) 版本: lite-http-2.1.5.jar 继承HttpRichParamModel方式调试正常... 但是通过以下方式请求时, 发现日志中没有输出请求参数!!! LiteHttp liteHttp = LiteHttp.newApacheHttpClient(null); liteHttp.getConfig().setDebugged(true); liteHttp.executeAsync(new JsonRequest(new Goods(1, 0), ApiModel.class)); //LOG I/LiteHttp: lite http request: http://sgarss.com:8080/FruitLover/fruitlover/api/goods? , tag: null , method: Get , cache mode: null , thread ID: 7536 , thread name: lite-1 //param参数page和type没有输出...服务端也没有收到请求参数

/////////////////////////附加代码1 @HttpUri("http://sgarss.com:8080/FruitLover/fruitlover/api/goods") public static class Goods implements HttpParamModel { public Integer page; public Integer type; public Goods(Integer page, Integer type) { this.page = page; this.type = type; } }

//////////////////////附加代码2 public final class ApiModel { public Integer stateCode; public String message; public String result; public boolean isSuccess() { return stateCode == 200; } }

bf3400 commented 9 years ago

https://zybuluo.com/liter/note/186565

// HttpRichParamModel 如果json是[....]一个数组 也会抛异常 protected T data;

//////////////////// { "api": "com.xx.get.userinfo", "v": "1.0", "result": { "code": 200, "message": "success" }, "data": [1,2,3] }

litesuits commented 9 years ago

public class User extends ApiModel< ArrayList< Integer> > { // data的泛型一定要和json数据结构保持一致才行。 }

这样即可。

litesuits commented 9 years ago

随时可调用 response.printInfo(); 打印信息;注意异常日志

bf3400 commented 9 years ago

我使用的是fastjson, 重写Json没有parseArray方法

bf3400 commented 9 years ago

实现HttpParamModel接口, 参数没有传过去?

litesuits commented 9 years ago

不用parseArray,parse整个object。需要看你的代码,加QQ群47357508,找我(群主)细聊