pom.xml中加上
<dependency>
<groupId>no.api.freemarker</groupId>
<artifactId>freemarker-java8</artifactId>
<version>2.1.0</version>
</dependency>
配置freemarker的configration
this.configuration = new Configuration(); // Or get the configuration from your framework like DropWizard or Spring Boot.
this.configuration.setObjectWrapper(new Java8ObjectWrapper(Configuration.VERSION_2_3_31));
使用ninjafreamwork框架,版本6.9
添加conf/Ninja.java文件
public class Ninja extends NinjaDefault {
@Inject
protected TemplateEngineFreemarker templateEngineFreemarker;
@Override
public void onFrameworkStart() {
super.onFrameworkStart();
Configuration freemarkerConfiguration = templateEngineFreemarker.getConfiguration();
freemarkerConfiguration.setObjectWrapper(new Java8ObjectWrapper(Configuration.VERSION_2_3_31));
}
}
遇到问题:
Configuration中,最高版本是2_3_29