ajax实现为table添加数据定时刷新

    最近做个会议系统 要求从底层发送数据包后在前台显示数据并定时刷新  无赖 今天查了好多关于这方面的资料 终于搞定。    把代码贴一下以后做参考 2009-05-14

 

-------------------------------------action层的--------------------------------------------------------

public void conf_control()
 {
   confList = getConfInforDAO().getConfLists();(这点我写成从数据库读的 实则读的数据包)
   if(confList!=null)
   { 
        PrintWriter out = null;
      try{
     getResponse().setContentType("text/xml; charset=GB2312");
     out = getResponse().getWriter();
     out.println("");
     out.println("");
      for (int i = 0; i < confList.size(); i++) {
        TconfInfo info = confList.get(i);
        out.print("");
        out.print(""+info.getConfName()+"");
        out.print(""+info.getConfTopic()+"");
        out.print(""+info.getBeginTime()+"");
        out.print(""+info.getEndTime()+"");
        out.print(""+info.getCreateTime()+"");
        out.print(""+info.getConfSize()+""); 
        out.print("
");
       }
      out.print("
");
      out.flush();
         out.close();
      }catch(Exception exception)
      {
       System.out.println("出现异常 ╮(╯﹏╰)╭"); 
      }
   }else
   {
     System.out.println("没有数据");
     System.out.println("╮(╯﹏╰)╭"); 
   }
    
  
 } 

 

   

-----------------------------------------jsp页面-------------------------------------------------------

 

<%@ page language="java" contentType="text/html; charset=UTF-8"
 pageEncoding="UTF-8" import="java.net.URLEncoder"%>
<%@taglib uri="/struts-tags" prefix="s"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ include file="/head.jsp"%>




会议监控





 
 
 


 
  


 
       
            
      
 




 

 

 

 

 

 

 

 

 

你可能感兴趣的:(js/ajax,table,ajax,stylesheet,xmlhttprequest,function,exception)