你把struts 的所有包都放进去 .
我上次也是这样的.

解决方案 »

  1.   

    legacy类在struts-legacy.jar文件内。
      

  2.   

    另外,org.apache.struts.util.GenericDataSource类的基类是org.apache.struts.legacy.GenericDataSource.对于使用Struts配置是的DataSource,需要用到ActionServlet类的实例servlet,
    所以的常建议采用《JSP Web编程指南》中的方法,自己建立数据库连接类:
    ConnectionPool.java:
    package OST.jdbc.util;import java.sql.SQLException;
    import java.sql.Connection;
    import javax.sql.DataSource;public class ConnectionPool {  private DataSource ds;  private static ConnectionPool mySelf;
      private ConnectionPool(DataSource ds) {
        this.ds = ds;
      }
      public static void init(DataSource ds) {
        mySelf = new ConnectionPool(ds);
      } public static ConnectionPool getInstance() {    if (mySelf == null) {
          throw new IllegalStateException("Pool not initialized.");
        }
        return mySelf;  }  public Connection getConnection() throws SQLException {
        return ds.getConnection();
      }}
    --------------------------------------------------------------
    DBInitServlet.java:
    package OST.jdbc.util;import javax.servlet.http.HttpServlet;
    import javax.servlet.ServletConfig;
    import javax.servlet.ServletException;import java.sql.SQLException;
    import java.sql.Connection;
    import javax.sql.DataSource;import org.apache.struts.util.GenericDataSource;public class DBInitServlet extends HttpServlet {  public void init(ServletConfig config) throws ServletException {    super.init(config);    try {      GenericDataSource ds = new GenericDataSource();      ds.setDriverClass(getInitParameter("driverClass"));
          ds.setUrl(getInitParameter("jdbcURL"));
          ds.setMinCount(Integer.parseInt(getInitParameter("minCount")));
          ds.setMaxCount(Integer.parseInt(getInitParameter("maxCount")));
          ds.setAutoCommit(false);      ds.setUser(getInitParameter("user"));
          ds.setPassword(getInitParameter("password"));
          
          ds.open();      ConnectionPool.init(ds);    } catch (SQLException e) {
          e.printStackTrace();
          throw new ServletException("Unable to open datasource.");
        }
      }
    }
    ------------
    这样就可以在其它类中使用它。
    例如:
    Connection con = null;    try 
            {
           con = pool.getConnection();
           lykDAO m_lykDAO = new lykDAO(con);              String action=request.getParameter("action");
          
           if(action==null)action="find";
               
               if(action.equals("delete"))
               {
                   String expression=request.getParameter("expression");
                   m_lykDAO.removeID(expression);
               }
                ////////////
               if(action.equals("update"))
               {
                     String expression=request.getParameter("expression");
                     lyk m_lyk= new lyk(); 
                   //<update>
                     m_lyk.setUser_id(m_lykForm.getUser_id());
                     m_lyk.setPassword(m_lykForm.getPassword());
                     m_lyk.setName(m_lykForm.getName());
                     m_lyk.setDescription(m_lykForm.getDescription());
                     m_lyk.setWeb_site(m_lykForm.getWeb_site());
                     m_lyk.setAddress(m_lykForm.getAddress());
                     //</update>
                  
                   m_lykDAO.update(m_lyk,expression);
               }
    }