HttpUtils httpUtils = new HttpUtils();
httpUtils.send(HttpMethod.GET, Constants.NEWSCENTER_URL, new RequestCallBack() {
@Override
public void onSuccess(ResponseInfo<String> responseInfo) {
System.out.println("新闻中心数据访问成功: " + responseInfo.result);
// 处理数据.
processData(responseInfo.result);
}
@Override
public void onFailure(HttpException error, String msg) {
System.out.println("新闻中心数据访问失败: " + msg);
}
});
public class ConstantsUtils {
/**
* 服务器的地址
*/
public static final String SERVECE_URL="http://localhost:8080/zhbj";
/**
* 新闻中心的地址
*/
public static final String newscenter_url=SERVECE_URL+"/categories.json";
}
你在eclipse里配置tomcat了吗?你可以百度tomcat在eclipse里配置。
web项目用myeclipse比较好,有很多集成的工具
打开Eclipse的Server视图,右键new新建一个Server,然后再添加web项目试试。