提问人:Harshil Panwar 提问时间:11/16/2023 更新时间:11/16/2023 访问量:6
速度为普通字符串中存在的连字符提供解析异常
Velocity giving parsing exception for hyphen present in normal string
问:
对于字符串,速度引擎在计算时会抛出解析异常。#TestString (test-string this is random string)
org.apache.velocity.exception.ParseErrorException: Encountered "-" at PERSONALISATION[line 1, column 18]
Was expecting one of:
<RPAREN> ...
<WHITESPACE> ...
<WHITESPACE> ...
正在使用 Velocity 1.7,并且评估时传递的上下文为空,但转义工具除外。
VelocityContext velocityContext = new VelocityContext();
velocityContext.put("esc", new EscapeTool());
StringWriter writer = new StringWriter();
getVelocityEngine().evaluate(velocityContext, writer, "TEST-TEMPLATE", text);
答: 暂无答案
评论