首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

ajax+json前端分页小范例

2012-11-22 
ajax+json前端分页小实例前端jspajax_func.jspackage com.eamoi.ajaximport java.io.BufferedReaderimpo

ajax+json前端分页小实例
前端jsp



ajax_func.js

package com.eamoi.ajax;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;


public class NewsJsonService {

public NewsJsonService(){

}
public List getNews(){
StringBuffer sb = new StringBuffer();
List l = new ArrayList();
try{
//File f = new File(System.getProperty("user.dir")+File.separator+"src"+File.separator+"news.txt");
//FileReader fr = new FileReader(f);
//BufferedReader bf = new BufferedReader(fr);
//String strObj;
//while ((strObj = bf.readLine()) != null) {
//sb.append(strObj);
//}
Map map1 = new HashMap();
map1.put("0", "aa");
map1.put("1", "bb");
Map map2 = new HashMap();
map2.put("0", "aa2");
map2.put("1", "bb2");
Map map3 = new HashMap();
map3.put("0", "aa3");
map3.put("1", "bb3");
Map map4 = new HashMap();
map4.put("0", "aa4");
map4.put("1", "bb4");
Map map5 = new HashMap();
map5.put("0", "aa6");
map5.put("1", "bb6");
Map map6 = new HashMap();
map6.put("0", "aa6");
map6.put("1", "bb6");
Map map7 = new HashMap();
map7.put("0", "7aa");
map7.put("1", "b7b");
Map map8 = new HashMap();
map8.put("0", "a8a");
map8.put("1", "b8b");
Map map9 = new HashMap();
map9.put("0", "a9a");
map9.put("1", "b9b");
Map map10 = new HashMap();
map10.put("0", "a00a");
map10.put("1", "b00b");
Map map11 = new HashMap();
map11.put("0", "a111a");
map11.put("1", "b111b");
l.add(map1);
l.add(map2);
l.add(map3);
l.add(map4);
l.add(map5);
l.add(map6);
l.add(map7);
l.add(map8);
l.add(map9);
l.add(map10);
l.add(map11);
//for(int i= 0;i<2;i++){
//map.put(i+"", i+"s");
//}
//
//l = new ArrayList();
//for(int j=0;j<10;j++){
//l.add(map);
//}

}catch (Exception e){
e.printStackTrace();
}
return l;
}

public static void main(String[] args){
NewsJsonService nj = new NewsJsonService();
nj.getNews();
String i = "";
}

}

1 楼 gdqsh 2010-12-14   第一次发表文章  有点乱  见谅各位!!

热点排行
Bad Request.