在使用Spring中StoredProcedure类来对存储过程进行调用,需要dataSource,dataSource是在Tomcat启动时候就加载了。请问我能直接拿到dataSource对象吗?

解决方案 »

  1.   

    看来是提问提的不清楚`~~就是 使用了struts和spring整合。怎样在自己的类里面拿到spring配置文件里面加载的对象。
      

  2.   

    import org.springframework.web.context.WebApplicationContext;
    import org.springframework.web.context.support.WebApplicationContextUtils;
    WebApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(getServletContext());
    IUserDAO userDAO= (IUserDAO) ctx.getBean("userDAO");
    是这个意思吗?希望对你有帮助!