BeansWrapper.getDefaultInstance() is deprecated now, how to get java.lang.Math in freemarker?
Looking for something like ${X / (Math.pow(10, n))} in freemarker
Thanks, Giby
DefaultObjectWrapper
extends BeansWrapper
, so it still has the getStaticModels()
method.
// Do this where you initialize FreeMarker. The config variable is assumed
// to hold your `freemarker.template.Configuration` singleton.
// We assume that the objectWrapper was already configured, and that it
// extends BeansWrapper (e.g. DefaultObjectWrapper does).
BeansWrapper objectWrapper = (BeansWrapper) config.getObjectWrapper();
TemplateModel mathStatics = objectWrapper.getStaticModels().get(Math.class.getName());
config.setSharedVariable("Math", mathStatics);
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.