For a compact spin Riemannian manifold $(M,g^{TM})$ of dimension $n$ such that the associated scalar curvature $k^{TM}$ verifies that $k^{TM}\geqslant n(n-1)$, Llarull's rigidity theorem says that any area-decreasing smooth map $f$ from $M$ to the unit sphere $\mathbb{S}^{n}$ of nonzero degree is an isometry. We present in this paper a new proof for Llarull's rigidity theorem in odd dimensions via a spectral flow argument. This approach also works for a generalization of Llarrull's theorem when the sphere $\mathbb{S}^{n}$ is replaced by an arbitrary smooth strictly convex closed hypersurface in $\mathbb{R}^{n+1}$. The results answer two questions by Gromov.