If, upon the trial of such action, it is proved, or, upon judgment by default, it appear to the court, by affidavit, that the plaintiff had a right to commence such action according to the provisions of this chapter, he shall have judgment to recover the possession of the demised premises and costs.
§ 535.150, RSMo