springmvc中用注解写了一个定时器,想在其中获取web上下文servletContext,或者简单一点的获得当前项目的绝对路径怎么弄???
网上有人说这样:
WebApplicationContext webApplicationContext = ContextLoader.getCurrentWebApplicationContext();
ServletContext servletContext = webApplicationContext.getServletContext();
但是我获取的webApplicationContext是空的,会报异常。
http://blog.csdn.net/xiao_wgs69/article/details/11269391
spring的task没有用过,但是有更好的选型,quartz,关于spring和quartz的集成,可参考:http://git.oschina.net/wangkang/llsfw
希望能够帮到你.