在servlet的init()方法中调用
InputStream in = getClass().getResourceAsStream("配置文件路径+文件名");

解决方案 »

  1.   

    看了struts中Action.java,将它实现的代码转为自己的实现,如下
    context = getServletContext();
    moduleConfig = RequestUtils.getModuleConfig(request, context);
    ds=(DataSource)context.getAttribute("org.apache.struts.action.DATA_SOURCE" + moduleConfig.getPrefix());
    conn = ds.getConnection();
    为什么不行呢?
    ----------
    之前我是在这个servlet中用jdbc连接了一次,感觉应该可以用struts配置的连接吧?哪位朋友做过,请指教!谢谢
      

  2.   

    可以在web.xml加入数据库相关参数,然后通过request.getParameter读取.
      

  3.   

    leehuashi(leehuashi),这样不是用jdbc又连接了一次