The data were accumulated with
the HERMES forward spectrometer using the 27.6 GeV longitudinally polarized electron or positron beam of
HERA.
Exclusive electroproduction of $\omega$ mesons
on unpolarized hydrogen and deuterium targets is studied in the
kinematic region of $Q^2>1.0$~GeV$^2$, 3.0 GeV $< W <$ 6.3 GeV, and
$-t'< 0.2 $ GeV$^{2}$, while for $\rho^0$-meson production on a transversely polarized hydrogen target
$-t'< 0.4$ GeV$^{2}$ is used.
Spin-density matrix elements for $\omega$ production are presented in projections of $Q^2$ or $-t'$, while
the ratios of the helicity amplitudes for the reaction $\gamma^*+p \to \rho^0+p$
are obtained in the entire kinematic region. The usage of the transversely polarized target allows for
the first time the extraction of the ratios of certain nucleon-helicity-flip amplitudes to the natural-parity exchange amplitude
$T_{0\frac{1}{2}0\frac{1}{2}}$ without the nucleon-helicity flip describing the longitudinal $\rho^0$-meson production by the longitudinal
virtual photon.
Violation of $s$-channel helicity conservation is observed for both mesons.
A dominant contribution from unnatural-parity exchange (UPE) is established for special combinations of the $\omega$ spin-density matrix
elements. For $\rho^0$-meson production, the UPE amplitude without the nucleon-helicity flip, $U_{1\frac{1}{2}1\frac{1}{2}}$, is shown to be$
largest UPE amplitude.
Good agreement is found between the HERMES data on $\omega$ production on the proton and results of the
perturbative QCD-inspired Goloskokov-Kroll model that includes pion-pole contribution.