In the problem of trajectory optimization for unmanned aerial vehicles (UAVs) passing through multiple target points, continuous velocity and acceleration in the process of optimization are essential for maintaining a feasible trajectory. This paper proposes a multi-segment holistic Bezier shaping method (MHBSM) for dynamic trajectory optimization. The MHBSM not only achieves holistic optimization of UAVs passing through a multi-target trajectory but also ensures high-order continuity at the junctions of trajectory segments. Unlike methods that generate non-dynamic trajectories by connecting arcs and straight lines (such as Dubins curves) without considering speed changes, MHBSM optimizes the trajectory while taking into account the dynamics of UAVs. The method optimizes the differential flat output space of a fixed-wing UAV dynamic model and transforms the dynamic optimization problem into a three-dimensional position optimization problem. The problem is then further transformed into an optimization of control points using the Bezier curve. The resulting trajectory satisfies the dynamic constraints. In comparison to the Gaussian pseudospectral method (GPM), MHBSM achieves similar optimization results with only a 2.58% difference, while requiring approximately 1.36% of the computational time on average. The MHBSM demonstrates excellent convergence performance while satisfying the constraints of continuous acceleration and obstacle avoidance.