freemark 异常

现象:

前几天跟前端联调,freemark报异常如下:

For "#if" condition: Expected a boolean, but this has evaluated to a method+sequence (wrapper: f.e.b.SimpleMethodModel):

==> act.isCatAct [in template "pages/index.ftl" at line 97, column 42]

----Tip: Maybe using obj.something instead of obj.isSomething will yield the desired value.

 

分析:

看起来像是boolean型变量使用有错,前端是这样使用的:

                    <#if act.isCatAct>
                        <p class="f-fwb">●【${(act.activityStatus.desc)!''}】 ${(act.name)!''}</p>
                        <p>共${(act.totalConferenceCount)!''}个会场,可报名${(act.canApplyConfCount)!''}个,已报名${(act.appliedConfCount)!''}个</p>
                    </#if>

后端对象如下:

public class BriefActivityInfoVO implements Serializable{

    /** 类目活动运营创建 */
    private boolean isCatAct;

改了很多种引用方式都不对,仔细读了一下报错,好像是isCatAct这个变量名被freemark认为是函数了,java对象确实存在这个方法,查了一下freemark的文档,freemark先找方法名,再找变量名

 

解决:

将bool型变量去掉is前缀,前端直接act.catAct这样引用,不再报错

posted @ 2016-08-21 11:25  Mr.24点以后  阅读(1307)  评论(0编辑  收藏  举报