Let mu be a positive Borel measure on the interval [0, 1). For beta > 0, the generalized Hankel matrix H-mu,H-beta = (mu(n),k,beta)n,k >= 0 with entries mu(n,k,beta) = integral([0.1)) Gamma(n+beta)\n!Gamma(beta) t(n+k)d(mu)(t) induces formally the operator H-mu,H-beta(f) (z) = Sigma(infinity)(n=0) (Sigma(infinity)(k=0) mu(n,k,beta)a(k))z(n), on the space of all analytic function f (z) = Sigma(infinity)(k=0) a(k)z(n) in the unit disk D. In this paper, we characterize those positive Borel measures on [0, 1) such thatH(mu,beta)(f ) (z) =integral([0,1)) f(t)\(1-tz)(beta)d mu(t) for all f in the weighted Bergman spaces A(alpha)(p) (0 < p < infinity, alpha > -1), and among them, we describe those for which H-mu,H-beta (beta > 0) is a bounded (resp., compact) operator on weighted Bergman spaces A(p)(alpha) and Dirichlet spaces D-p(alpha).