开发者

In Freemarker templates, how do you get the name of the data model's class?

I开发者_运维知识库'm using Freemarker to generate an XHTML page from a POJO which contains a List of Objects, all of which are instances of subclasses of the same parent class. I'd like to generate different information for each object based on its class. How do you test for that in the Freemarker language? For example, if I had a List, how would I determine if a particular Shape was a Rectangle or a Circle?


${class.name}

Though I suggest you consider using a method from each class to generate the unique behavior for each subclass. Polymorphism is a wonderful thing. :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜