In this work, a facile method was developed to prepare mesoporous polyaniline (mPANI) hollow nanospheres using core/shell structured silica nanospheres as substrates. The prepared mPANI hollow nanospheres were composed of external mesoporous PANI shell and internal mesoporous resorcinol-formaldehyde (RF) resin shell. The average diameter, shell thickness, specific area, average pore diameter, and total pore volume of mPANI hollow nanospheres were 330 nm, 78 nm, 75 m2 g−1, 6.9 nm, and 0.89 cm3 g−1, respectively. 1H-benzotriazole (BTAH) loading rate in mPANI hollow nanospheres was up to 35%. In addition, BTAH can be released from mPANI hollow nanospheres continuously to provide a sustained protection for epoxy coating. Epoxy coating pigmented with 2 wt% mPANI hollow nanospheres loaded with BTAH (mPANI@BTAH) presents remarkable anticorrosion property, and its coating resistance still can be maintained at 109 Ω cm2 even after 60-day immersion in 3.5 wt% NaCl solution. Furthermore, there are only slight rusts at the scratch after 30-day salt spray test, and the coating adhesion force reduced a little, still up to 6.4 MPa, indicating excellent anticorrosion property. Meanwhile, scanning vibrating electrode technique (SVET) results confirmed that epoxy coating pigmented with mPANI@BTAH hollow nanospheres exhibited obvious self-healing function. It can be concluded from the series tests that mPANI@BTAH hollow nanospheres as high performance anticorrosion pigments can strongly improve the anticorrosion performance of epoxy coating through combining the passivating function of polyaniline and corrosion inhibition of BTAH together.