enjoy模板的输出指令#()的参数名有要求吗?目前包含.会报错:
com.jfinal.template.stat.ParseException: Expression error: can not match "."
模板里面使用:
#(ZONGJC.0001-DAYFINISH.FINISH)
我渲染的数据是:
Map<String, Object> dataMap = Kv.by("ZONGJC.0001-DAYFINISH.FINISH", 2000).set("ZONGJC.0001-DAYFINISH.PLAN", 1000);
key是包含.和-的(历史项目,如果要修改key格式很麻烦),有没有办法来支持.??
import com.jfinal.template.Directive;
import com.jfinal.template.Env;
import com.jfinal.template.io.Writer;
import com.jfinal.template.stat.Scope;
public class ValueDirective extends Directive {
public void exec(Env env, Scope scope, Writer writer) {
String key = (String)exprList.eval(scope);
if (key != null) {
Object value = scope.get(key);
if (value != null) {
write(writer, value.toString());
}
}
}
}
然后配置一下:
engine.addDirective("value", new ValueDirective());
用的时候注意要这样用:
#value("ZONGJC.0001-DAYFINISH.FINISH");