TimerTask能不能调用
这段代码可以
public class SaveTroubleTimer extends TimerTask {
@Override
public void run() {
SaveTrouble1Action st1a = new SaveTrouble1Action();
st1a.saveTrouble();
}
}
请问st1a能不能调用ActionForward
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
throws Exception
{
System.out.println("2");
return null;
}
------解决方案--------------------
HttpServletRequest request
在你的定时器里面是不能获取request的!!!
所以、Action不能访问!
------解决方案--------------------你是要做定时任务? 可以看看Spring+quartz
------解决方案--------------------
你的sessionFactory是怎么获取的?
Configuration configuration = new Configuration();
configuration.configure("/hibernate.cfg.xml");
org.hibernate.SessionFactory sessionFactory = configuration.buildSessionFactory();