标签:文章标题 web.xml java web servlet ssh
<servlet> <servlet-name>listener</servlet-name> <servlet-class>MEMBCERP.Servlet.servletlistener</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>listener</servlet-name> <url-pattern>/listener.do</url-pattern> </servlet-mapping>
package MEMBCERP.Servlet; import java.util.Timer; import javax.servlet.ServletConfig; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; public class servletlistener extends HttpServlet { /*监听转发系统代理事件*/ private Timer timer = null; public void init(ServletConfig config) throws ServletException{ super.init(config); timer = new Timer(true); timer.schedule(new Todo(), 0, 1000); /*参数:方法重定向,延迟,执行时间的间隔*/ } }最后,便是监听到符合程序,满足条件便自行进行系统维护了,代码如下:
package MEMBCERP.Servlet; import java.text.SimpleDateFormat; import java.util.Date; import java.util.TimerTask; import MEMBCERP.IService.JianKaYuFaFangIService; import MEMBCERP.Service.JianKaYuFaFangService; import MEMBCERP.pojo.SysMaxNumber; public class Todo extends TimerTask{ @Override public void run(){ SimpleDateFormat df = new SimpleDateFormat("HH:mm:ss");//设置日期格式 String timDate=df.format(new Date()); //监听是否进行日常维护 if (timDate.equals("00:00:00")) { ChuShiHuaZuiDaDanJuShu(); } } public JianKaYuFaFangIService jianKaYuFaFangService=new JianKaYuFaFangService(); //实例化类 //初始化当日最大单据数 public void ChuShiHuaZuiDaDanJuShu() { SysMaxNumber lstZuiDaDanJuShu=new SysMaxNumber(); lstZuiDaDanJuShu.setDiaoBoJiLuZuiDaShu(0); lstZuiDaDanJuShu.setFaFangJiLuZuiDaShu(0); lstZuiDaDanJuShu.setGuaShiHuiFuJiLuZuiDaShu(0); lstZuiDaDanJuShu.setHuiYuanKaZuoFeiJiLuZuiDaShu(0); lstZuiDaDanJuShu.setHuiYuanKaHuanKaJiLuZuiDaShu(0); lstZuiDaDanJuShu.setHuiYuanKaYouXiaoQiGengGaiJiLuZuiDaShu(0); lstZuiDaDanJuShu.setHuiYuanKaZhuangTaiBianDongJiLuZuiDaShu(0); lstZuiDaDanJuShu.setId(0); lstZuiDaDanJuShu.setKuCunKaYouXiaoQiBianGengJiLuZuiDaShu(0); lstZuiDaDanJuShu.setKuCunKaZuoFeiJiLuZuiDaShu(0); lstZuiDaDanJuShu.setLingKaJiLuZuiDaShu(0); lstZuiDaDanJuShu.setTuiLingJiLuZuiDaShu(0); lstZuiDaDanJuShu.setGuaShiJiLuZuiDaShu(0); lstZuiDaDanJuShu.setJianKaJiLuZuiDaShu(0); lstZuiDaDanJuShu.setKuCunKaZuoFeiHuiFuJiLuZuiDaShu(0); this.jianKaYuFaFangService.UpdateZuiDaDanJuShu(lstZuiDaDanJuShu); } }
标签:文章标题 web.xml java web servlet ssh
原文地址:http://blog.csdn.net/qqs819439054/article/details/46626491