首页 > 编程语言 > 详细

spring定时器中如何获取servletcontext

时间:2017-11-11 11:02:53      阅读:263      评论:0      收藏:0      [点我收藏+]

spring定时器中如何获取servletcontext

学习了:https://zhidao.baidu.com/question/406212574.html

@Scheduled(cron = "0 0 */3 * * ?") // 3小时处理一次
    public void updateData(){
        System.out.println("*********************************schedule task");
        WebApplicationContext webApplicationContext = ContextLoader.getCurrentWebApplicationContext();
        ServletContext context = webApplicationContext.getServletContext();
        List<Tbl> tblList = tblMapper.getAll();
        context.setAttribute("tbl", tblList);
         
    }

 

spring定时器中如何获取servletcontext

原文:http://www.cnblogs.com/stono/p/7818250.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!