We propose a conservative energy method based on a neural network with subdomains (CENN), where the admissible function satisfying the essential boundary condition without boundary penalty is constructed by the radial basis function, particular solution neural network, and general neural network. The loss term at the interfaces has the lower order derivative compared to the strong form PINN with subdomains. We apply the proposed method to some representative examples to demonstrate the ability of the proposed method to model strong discontinuity, singularity, complex boundary, non-linear, and heterogeneous PDE problems. The advantage of the method is the efficiency and accuracy compared to the strong form PINN. It is worth emphasizing that the method has a natural advantage in dealing with heterogeneous problems.