We study the γ-ray spectra of 30 globular clusters (GCs) thus far detected with the Fermi Gammaray Space Telescope. Presuming that γ-ray emission of a GC comes from millisecond pulsars (MSPs) contained in, a model that generates spectra for the GCs is built based on the γ-ray properties of the detected MSP sample. We fit the GCs' spectra with the model, and for 27 of them, their emission can be explained with arising from MSPs. The spectra of the other three, NGC 7078, 2MS-GC01, and Terzan 1, can not be fit with our model, indicating that MSPs' emission should not be the dominant one in the first two and the third one has a unique hard spectrum. We also investigate six nearby GCs that have relatively high encounter rates as the comparison cases. The candidate spectrum of NGC 6656 can be fit with that of one MSP, supporting its possible association with the γ-ray source at its position. The five others do not have detectable γ-ray emission. Their spectral upper limits set limits of mostly ≤ 1 MSPs in them, consistent with the numbers of radio MSPs found in them. The estimated numbers of MSPs in the γ-ray GCs are generally larger than those reported for radio pulsars, suggesting more MSPs in them than those currently revealed. Our studies of the γ-ray GCs and the comparison nearby GCs indicate that the encounter rate should not be the only factor determining the number of MSPs a GC contains.