Spring 是我们在web开发中比较熟悉的一个框架,
如今进军到Android中了.
我也来小试一下牛刀
下面是Spring-android 解析json的代码,
服务器返回数据为:
{"id":"1","word":"the word","translation":"那个单词"}
客户端代码:
class Word { private int id; private String word; private String translation;
// getter & setter }
String url = "http://localhost:8080/test/getmsg.action"; RestTemplate template = new RestTemplate(); Word word = template.<Word> getForObject(url, Word.class);
灰常给力的东西, 我还在继续研究. .
在使用时请导入
spring-android-core-1.0.0.RELEASE.jar
spring-android-rest-template-1.0.0.RELEASE.jar
jar 包的下载地址奉上:http://download.csdn.net/detail/double_t_abner/4642403