简体   繁体   中英

Apache velocity multiple variables

I am using apache velocity to generate multiple templates, the problem is that in each templates multiple (read many) variables are being used and it becomes very tedious to initialize each and every variable seperately.

Is there a work around this or i have no other option?

See there are two work around this thing, the 1st and the best option is that you create a Java Bean class that will contain all your template variables and you can then just initialise separate objects for each and every instance of your template, you just have merge the object with context.

Another way is creating and using a java property file which is not only tedious as you have to create separate property file for each and every time you want to create a new file from your template but also deprecated.

You can read about this more on Apache velocity official documentation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM