JSP中页面自动定时刷新

来源:互联网 发布:sql查询第几位数据 编辑:程序博客网 时间:2024/05/17 01:42



1.JSP中页面定时刷新

Java代码
  1. <%  
  2.    //页面每隔30秒自动刷新一遍      
  3.    response.setHeader("refresh","30");  
  4. %>  
[java] view plain copy
print?
  1. <%  
  2.    //页面每隔30秒自动刷新一遍      
  3.    response.setHeader("refresh","30");  
  4. %>  



2.JSP中页面定时刷新至另一个指定页面

Java代码
  1. <%  
  2.     //页面每隔30秒自动链接至另一页面  
  3.     response.setHeader("refresh","30;URL=http://www.sina.com");  
  4. %>  
[java] view plain copy
print?
  1. <%  
  2.     //页面每隔30秒自动链接至另一页面  
  3.     response.setHeader("refresh","30;URL=http://www.sina.com");  
  4. %>  



3.<meta http-equiv="refresh" content="30">

Java代码
  1. <%@ page contentType="text/html;charset=GBK" %>  
  2. <%  
  3.   //页面每隔30秒自动刷新一遍      
  4.   response.setHeader("refresh","10;URL=http://www.sina.com");  
  5.   
  6. %>  
  7. <html>  
  8.   <head>  
  9.     <title>My JSP 'index.jsp' starting page</title>  
  10.     <!--  <meta http-equiv="pragma" content="no-cache">  
  11.     <meta http-equiv="cache-control" content="no-cache">  
  12.     <meta http-equiv="expires" content="0">      
  13.     <meta http-equiv="refresh" content="30"> -->  
  14.     <script type="text/javascript">  
  15.        alert("jsp");  
  16.     </script>  
  17.   </head>  
  18.     
  19.   <body>  
  20.     This is my JSP page. <br>  
  21.   </body>  
  22. </html> 
原创粉丝点击