当前位置: 首页 > news >正文

工程建设造价全过程监督网站采集插件wordpress

工程建设造价全过程监督网站,采集插件wordpress,wordpress 图片 视频播放,网页制作工具的选择与网站整体风格是有关系的在服务器与客户端之间通信#xff0c;json数据是一种常用格式#xff0c;本文主要在服务器端构建数据#xff0c;在客户端接收显示#xff0c;并且在listview上显示出来 服务器端的构建 简单的javabean与返回结果函数与插入函数略过 public void doGet(HttpServletReque…在服务器与客户端之间通信json数据是一种常用格式本文主要在服务器端构建数据在客户端接收显示并且在listview上显示出来 服务器端的构建 简单的javabean与返回结果函数与插入函数略过 public void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {response.setContentType(text/html);response.setCharacterEncoding(UTF-8);PrintWriter out response.getWriter();ListMyShop shops JsonService.getListShop();StringBuffer sb new StringBuffer();sb.append([);for (MyShop shop : shops) {sb.append({).append(\name\:).append(\shop.getName()\).append(,); sb.append(\detail\:).append(\shop.getDetail()\).append(,);sb.append(\distance\:).append(\shop.getDistance()\).append(,);sb.append(\address\:).append(\shop.getAddress()\).append(,);sb.append(\popularity\:).append(shop.getPopularity());sb.append(}).append(,);}sb.deleteCharAt(sb.length() - 1);sb.append(]);out.write(new String(sb));out.flush();out.close();} 在浏览器中直接输入访问http://localhost:8080/AppServer/JsonServlet 可得 可以在服务器端直接查看json数据 客户端接收与解析json数据 public class JsonParse {/*** 解析Json数据** param urlPath* return mlists* throws Exception*/public static ListMyShop getListShop(String urlPath) throws Exception {ListMyShop mlists new ArrayListMyShop();byte[] data readParse(urlPath);JSONArray array new JSONArray(new String(data));for (int i 0; i array.length(); i) {JSONObject item array.getJSONObject(i);String name item.getString(name);String detail item.getString(detail);String distance item.getString(distance);String popularity item.getString(popularity);String address item.getString(address);mlists.add(new MyShop(name, detail, distance,address,popularity));}return mlists;}/*** 从指定的url中获取字节数组** param urlPath* return 字节数组* throws Exception*/public static byte[] readParse(String urlPath) throws Exception {ByteArrayOutputStream outStream new ByteArrayOutputStream();byte[] data new byte[1024];int len 0;URL url new URL(urlPath);HttpURLConnection conn (HttpURLConnection) url.openConnection();InputStream inStream conn.getInputStream();while ((len inStream.read(data)) ! -1) {outStream.write(data, 0, len);}inStream.close();return outStream.toByteArray();}} 在activity中开启子线程来接收服务器数据 new Thread(new Runnable() {private String tag;Overridepublic void run() {// TODO Auto-generated method stub//获得新闻集合ListMyShop shopList null;try {shopList JsonParse.getListShop(http://192.168.247.1:8080/AppServer/JsonServlet);} catch (Exception e) {// TODO Auto-generated catch blocke.printStackTrace();}Log.i(tag, 在RUN中LIST长度为shopList.size());Message msgnew Message();if(shopList!null){msg.whatSUCCESS;msg.objshopList;}else{msg.whatFAILED;}handler.sendMessage(msg);Log.i(tag, ***********T长度为shopList.size());}}).start(); 消息处理器 //消息处理器private Handler handlernew Handler(){/*** 接收消息*/Overridepublic void handleMessage(Message msg) {// TODO Auto-generated method stubString tag null;switch (msg.what) {case SUCCESS: //访问成功有数据//绑定数据Log.i(tag,%%%%%%%%%%到达了消息处理器);myshoplist(ListMyShop) msg.obj;Log.i(tag, handleMessage中数据newInfoList长度为myshoplist.size());NearAdapter adapternew NearAdapter();Log.i(tag, 有没有到达ADAPTERadapter.getCount());showList.setAdapter(adapter);break;case FAILED: //访问失败Toast.makeText(ChooseMer.this, 当前网络崩溃了, 0).show();break;default:break;}}}; 配置适配器 public class NearAdapter extends BaseAdapter {Overridepublic int getCount() {// TODO Auto-generated method stubreturn myshoplist.size();}Overridepublic Object getItem(int position) {// TODO Auto-generated method stubreturn null;}Overridepublic long getItemId(int position) {// TODO Auto-generated method stubreturn 0;}Overridepublic View getView(int position, View convertView, ViewGroup parent) {if (convertView null) {LayoutInflater inflater LayoutInflater.from(ChooseMer.this);convertView inflater.inflate(R.layout.nearby_list_item, null);init(convertView,position);}return convertView;}public void init(View convertView,int position) {hold.name (TextView) convertView.findViewById(R.id.nearby_item_name);MyShop shopmyshoplist.get(position);hold.name.setText(shop.getName());hold.local (TextView) convertView.findViewById(R.id.nearby_item_local);hold.local.setText(shop.getDetail());hold.dis1 (TextView) convertView.findViewById(R.id.nearby_item_dis1);hold.dis1.setText(shop.getDistance());hold.dis2 (TextView) convertView.findViewById(R.id.nearby_item_dis2);hold.dis2.setText(shop.getAddress());hold.dis3 (TextView) convertView.findViewById(R.id.nearby_item_dis3);hold.dis3.setText(shop.getPopularity());}} 配置完成效果如下
http://www.huolong8.cn/news/189576/

相关文章:

  • 重庆巴南区网站开发网站横幅广告代码
  • 百度首页网站的设计梧州网站制作公司
  • 互联网设计是做什么的seo优化软件oem
  • vs 2017c 怎么建设网站做淘客网站 知乎
  • 最新网站建设进程手机网站需要备案吗
  • 十大招聘网站排行榜wordpress修改后台管理地址=
  • 微网站建设要多少钱深圳vi设计手册
  • 广州网站制作是什么网站更新怎么做
  • 如何给网站设置关键词网站结构有哪几种
  • 哈尔滨网站建设方案开发php手机网站开发
  • 萝岗移动网站建设模板之家html
  • 网站开发读什么专业网页传奇游戏怎么注销
  • 昆明做网站公司有哪些哈尔滨网站优化推广公司
  • 网络营销推广为什么效果不好济南好的seo
  • 培训网页seo上词价格
  • 公司注销后网站备案吗wordpress 链接扁平化
  • 热水器网站建设 中企动力马克飞象 wordpress
  • 电影网站标题怎么做流量多新都区建设局网站
  • 营销型网站如何建设wordpress跳转设置
  • 哪些网站可以做淘宝推广免费网站app软件
  • 网站和网址有什么不同百度后台登陆入口
  • 众筹网站怎么做成都外贸网站建设
  • 连云港网站建设的公司叮当快药网站谁做的
  • 网站上传空间的ip地址网址转app制作生成器
  • 网站后台中文模板有做喜糖的网站吗
  • 做的比较好的车载嗨曲网站网站开发感受
  • wordpress生成站点地图郭仓镇做网站
  • 如何建设网站app德网站建设
  • 营销型网站建设 多少钱seo技术建站
  • 深圳市公司网站建设平台全屋定制十大名牌排行最新