I know this question already has an accepted answer, but I'm still writing a piece of code that might be useful to someone else.
Use below code snippet in java
BeansWrapper w = new BeansWrapper(); TemplateModel statics = w.getStaticModels(); map.put("statics", statics); // map is java.util.Map template.process(map, out); // template is freemarker.template.Template
Then the access constant in ftl
${statics["com.model.to.gen.Common"].FLAG_YES}
here com.model.to.gen.Common is a class, and FLAG_YES is a static constant.
source share