这个刷新并不是单纯的去刷新页面,而是:
比如:我定好了时间是10:20 当系统检查到时间到了10:20,就自动去执行更新数据库的操作.
这里的更新数据库是把数据库内的某一个字段值给更新了,比如我设定中午十二点将"GOOD"数据库内的"LOVE"字段的值都改为"我不爱你"
这个怎么实现呢,想了好长时间,没个头绪.
谢谢各位!
首先:timer 或者 quartz 完全满足你的需求!
如果时间要求不是 非常精准的话 可以
在页面 写个js window.setTimeOut();
每1秒刷新一次! 判断是否到时间了! 到了 调用下你的 修改 操作! OK!
:wink:
[quote]public class Task_M implements ServletContextListener { //implements ServletContextListener
/**
定时器
*/
private Task_M timer;
public Task_M () {
}
/**
在Web应用启动时初始化任务
@param sce ServletContextEvent
*/
public void contextInitialized(ServletContextEvent sce ) {
//定义定时器
timer = new Timer(true);
Date now = new Date();
int year = now.getYear();
int month = now.getMonth();
int day = now.getDate();
timer.schedule("修改操作",new Date(year, month, day, 10, 20, 0),MILLIS_IN_DAY); // 10:20 执行的任务 定时器!
}
/**
}[/quote]
试试看!