What are "Sha'arei Tzedek"?
Rashi: It is like verse 20 says - the gate of the Beis ha'Mikdash, which is of Hashem, and Tzadikim come in it 1 .
Rashi (27): They are gates of Batei Kenesiyos and Batei Midrash 2 . They are of Hashem, and Tzadikim enter them.
Malbim: The king and Tzadikim with him came to offer Todos and Korbanos of the day. Since the salvation came via afflictions, this is Midas ha'Tzedek (based on deeds), and not via Chesed.
Rashi explained that this is if the verse refers to David. Perhaps since the Beis ha'Mikdash was not built in his days, we are forced to say that "Sha'arei Tzedek" are not of the Beis ha'Mikdash. (PF)
How will the gates be opened?
Radak: This is a metaphor for words of praise and thanks to Hashem, who saved me. He tells Chachamim and those who know, to help him to praise Him.
Malbim: He calls to the gatekeepers to open them.