调用Thymeleaf 编译模板文件
public static String compile() {
TemplateEngine templateEngine = new TemplateEngine();
ClassLoaderTemplateResolver templateResolver = new ClassLoaderTemplateResolver();
templateResolver.setPrefix("templates/");//指定模版前缀,即存放位置,默认是该地址
templateResolver.setSuffix(".xml");//指定模版后缀
templateResolver.setTemplateMode(TemplateMode.XML);//指定使用‘XML’模式
templateResolver.setCharacterEncoding("UTF-8");//指定使用‘UTF-8’编码
templateResolver.setCacheable(true);//开启缓存
templateEngine.setTemplateResolver(templateResolver);
Context ctx = new Context(Locale.getDefault());
ctx.setVariable("SpatialReference", "SpatialReference11111");
String htmlContent = templateEngine.process("sdtemplates/tilingserverics.xml", ctx);
return htmlContent;
}