Stringtemplate比较字符串不起作用 [英] Stringtemplate compare strings does not work

查看:259
本文介绍了Stringtemplate比较字符串不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以解释为什么这不起作用吗?

Can someone explain why this does not work ?

StringTemplate query = new StringTemplate("hello " +  
                "$if(param==\"val1\")$" +  
                " it works! " +  
                "$endif$ " +  
                "world");  
        query.setAttribute("param", "val1");  
        System.out.println("result: "+query.toString());  

抛出

eval树解析错误
:0:0:org.antlr.stringtemplate.language.ActionEvaluator.ifCondition(ActionEvaluator.java:815)
org.antlr.stringtemplate.language.ConditionalExpr的子树
的意外结束.write(ConditionalExpr.java:99)

eval tree parse error :0:0: unexpected end of subtree at org.antlr.stringtemplate.language.ActionEvaluator.ifCondition(ActionEvaluator.java:815) at org.antlr.stringtemplate.language.ConditionalExpr.write(ConditionalExpr.java:99)

推荐答案

ST不允许在模板中进行计算。这将使其成为模型的一部分。

ST doesn't allow computation in the templates. That would make it part of the model.

这篇关于Stringtemplate比较字符串不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆