建议使用org.apache.struts.Globals.DATA_SOURCE_KEY

解决方案 »

  1.   

    呵呵使用
    Connection conn=null;
        ResultSet rs=null;
        PreparedStatement pstmt=null;
        String sql="select * from user where UserName=?";
        DataSource ds=getDataSource(request, "dataSource");
        try{
          conn = ds.getConnection();
          pstmt=conn.prepareStatement(sql);
          pstmt.setString(1,loginForm.getUsername());
          rs=pstmt.executeQuery();
          if(rs.next()){
            myaction = mapping.findForward("success");
            request.setAttribute("username",loginForm.getUsername());
          }else{
            myaction = mapping.findForward("error");
          }
          conn.close();
        }catch(SQLException ex){
          ex.printStackTrace();
        }
        return myaction;