现象:

前几天跟前端联调,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型变量使用有错,前端是这样使用的:

freemark 异常

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

后端对象如下:

freemark 异常

public class BriefActivityInfoVO implements Serializable{

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

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

 

解决:

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

freemark 异常

相关文章:

  • 2022-12-23
  • 2021-07-04
  • 2021-12-12
  • 2022-12-23
  • 2022-12-23
  • 2021-08-19
  • 2022-02-05
  • 2021-08-10
猜你喜欢
  • 2022-12-23
  • 2021-10-05
  • 2021-05-21
  • 2022-12-23
  • 2021-04-17
  • 2022-03-07
  • 2022-12-23
相关资源
相似解决方案