פִּתְחוּ־לִ֥י שַׁעֲרֵי־צֶ֑דֶק אָֽבֹא־בָ֝ם אוֹדֶ֥ה יָֽהּ׃
내게 의의 문을 열지어다 내가 들어가서 여호와께 감사하리로다
Rashi
Open for me the gates of righteousness And these are the gates of righteousness.
Malbim
Open (the king and the upright ones who went with him arrived at the Temple to give thanks and to bring their offerings of thanksgiving and sacrifice that day), and this [opening] is a mitzvah for the gatekeepers that they should open the gates of justice for him these are the gates of the Temple so that he may enter and thank H' He called them the gates of justice because after his salvation came by means of chastisements, H' treated him in accordance with the attribute of justice according to his actions, and not in accordance with the attribute of kindness.
Ibn Ezra
He who was rescued, he is obligated to thank Him. This is righteousness.