Java代码
  1. <%@page trimDirectiveWhitespaces="true"%>  
  2. <%@page language="java" pageEncoding="utf-8"%>  
  3. <%@page import="sun.misc.*"%>  
  4. <%@page import="java.io.*"%>  
  5. <%@page import="java.util.*"%>  
  6. <%  
  7. List<String> htmltempList=new ArrayList<String>();  
  8. //String[][] students = {{'小明','1101','23','52819911'},{'夏利','1101','23','52819911'},{'小强','1102','21','52819901'}};  
  9.   
  10. //创建6行4列二位数组  
  11. String[][] book=new String [6][4];  
  12. book[0]=new String[]{"风清扬","1101","23","52819911"};  
  13. book[1]=new String[]{"许志飞","1101","23","52819911"};  
  14. book[2]=new String[]{"令狐冲","1102","21","52819901"};  
  15. book[3]=new String[]{"任我行","1103","22","52819991"};  
  16. book[4]=new String[]{"任盈盈","1104","24","52819981"};  
  17. book[5]=new String[]{"东方不败","1105","26","52819981"};  
  18.   
  19. String[][] arr1={{"11","22"},{"aaa","bbb"},{"AAA","BBB"}};  
  20. String[][] arr2=new String[3][2];  
  21. for(int i=0;i<book.length;i++){  
  22.     htmltempList.add("<ul>");  
  23.     for(int j=0;j<book[i].length;j++){  
  24.         //out.println(book[i][j]);  
  25.         htmltempList.add("<li>" +book[i][j]+"</li>");  
  26.     }  
  27.     htmltempList.add("</ul>");  
  28. }  
  29.   
  30. /*
  31. int [][]a=new int[8][8];
  32. for (int i=0;i<8;i++){
  33.    for(int j=0;j<8;j++){
  34.     a[i][j]=i+j;
  35.     out.println(a[i][j]+"---");
  36.    }
  37. }*/  
  38. //out.println("---");  
  39.   
  40. %>  
  41.   
  42. <%  
  43. for (int i=0;i<9;i++){  
  44. //htmltempList.add("<li><span>" + i+"</span></li>");  
  45. }  
  46. /*
  47. for (int i=0; i<htmltempList.size();i++){
  48. out.print(htmltempList.get(i));
  49. }
  50. out.print(testCol(htmltempList) + "====================");
  51. */  
  52. %>  
  53. <%  
  54. response.setContentType("text/json");  
  55. response.setCharacterEncoding("utf-8");  
  56. String callback=request.getParameter("Jsoncallback");  
  57. if(callback!=null&&!"".equals(callback)){  
  58.     out.print(callback+"({\"dataList\":\"" +testColCon(htmltempList) + "\"})");  
  59. }  
  60.   
  61. %>  
  62. <%!  
  63. public static int testCol(List<String> testList){  
  64. return testList.size();  
  65. }  
  66. public static String testColCon(List<String> testList){  
  67. String str="";  
  68. String html="<style>*{margin:0;padding:0;}h1{font-size:16px;text-align:center; line-height:45px;}body{color:#333;font-size:14px;font-family:'MicrosoftYahei';background:#B7CACC;}div{border:1px solid #405E7B; border-bottom:0; width:95%; margin:0 auto;background:#fff;content:'';display:table;clear:both}li{line-height:35px;list-style:none;width:25%;text-align:center;border-bottom:1px solid #405E7B;float:left;}</style><h1>最近风云人员名单</h1><div>";  
  69. for (int i=0; i<testList.size();i++){  
  70.     str+=testList.get(i);  
  71. }  
  72. html+=str;  
  73.         byte[] b=null;  
  74.         String s=null;  
  75.         try{    
  76.             b=html.getBytes("utf-8");  
  77.         }catch(UnsupportedEncodingException e){  
  78.             e.printStackTrace();    
  79.         }    
  80.         if (b!=null){  
  81.             s=new BASE64Encoder().encode(b);    
  82.               
  83.             s=s.replaceAll("\r\n","");  
  84.             s=s.replaceAll("\n","");  
  85. //          s = s.replaceAll("","");  
  86.             //s="PGxpPjxzcGFuPjA8L3NwYW4+PC9saT48bGk+PHNwYW4+MTwvc3Bhbj48L2xpPjxsaT48c3Bhbj4yPC9zcGFuPjwvbGk+PGxpPjxzcGFuPjM8L3NwYW4+PC9saT48bGk+PHNwYW4+NDwvc3Bhbj48L2xpPjxsaT48c3Bhbj41PC9zcGFuPjwvbGk+PGxpPjxzcGFuPjY8L3NwYW4+PC9saT48bGk+PHNwYW4+Nzwvc3Bhbj48L2xpPjxsaT48c3Bhbj44PC9zcGFuPjwvbGk+";  
  87.         }    
  88.         return s;  
  89.               
  90. }  
  91.   
  92. %>  
PHP/Java/Go | 评论(0) | 引用(0) | 阅读(3587)