【发布时间】:2013-10-29 06:10:20
【问题描述】:
如何使用 SimpleTemplateEngine 或 GStringTemplateEngine 处理大于 65535 个字符的模板?
我收到以下错误:
groovy.lang.GroovyRuntimeException: 无法解析模板脚本(您的模板可能包含错误或尝试使用当前不支持的表达式):启动失败: SimpleTemplateScript1.groovy:5614:字符串太长。给定的字符串长度为 198495 个 Unicode 代码单元,但最多允许 65535 个。
我正在使用以下代码构建模板:
def templateEngine = new SimpleTemplateEngine()
def binding = [:]
templateEngine
.createTemplate(new FileReader("input.txt))
.make(binding)
.writeTo(new FileWriter(new File("output.txt")))
我发现 JIRA 3487 与此问题相关:GStringTemplateEngine fails to work with >64K strings 。
我曾考虑过对输入进行分块,但这会带来其自身的复杂性,例如确保不会在表达式中间中断。
如果有任何其他建议,我将不胜感激。
【问题讨论】:
标签: groovy