【问题标题】:Can anyone spot the syntax error in this freemarker macro谁能发现这个 freemarker 宏中的语法错误
【发布时间】:2012-11-12 08:48:46
【问题描述】:
<#macro inputValidatedTextCell name size=30  vreq="N" vtype="" class="" maxlength="" default="" index=-1 password=false readonly=false onChange="" id="" ignoreParameters=false errorField="" tabIndex="" colspan="" tooltip="">
   <#if ( vreq.equals("Y") && (!vtype.equals("")))><#assign vclass = "validation[required,custom[${vtype}}]]"><#elseif vreq.equals("Y")><#assign vclass = "validate[required]"><#else><#assign vclass = "validation[custom[${vtype}]]"></#if>
  <td<#if colspan?has_content>colspan="${colspan}"</#if>>
  <@inputText name=name id=name class=vclass
  size=size maxlength=maxlength default=default index=index password=password readonly=readonly onChange=onChange ignoreParameters=ignoreParameters errorField=errorField tabIndex=tabIndex tooltip=tooltip/>
  </td>
</#macro>

我收到此错误: Expected hash. vreq evaluated instead to freemarker.template.SimpleScalar on line 300, column 11 in opentapsFormMacros. The problematic instruction: ---------- ==&gt; if-else [on line 300, column 4 in opentapsFormMacros] in user-directive inputValidatedTextCell [on line 17, column 5 in component://multitenancy-support/webapp/multitenancy-support/controlpanel/replenishmentConfigForm.ftl] in user-directive frameSection [on line 2, column 1 in ....etc....

【问题讨论】:

    标签: freemarker


    【解决方案1】:

    这不是语法错误,而是运行时错误。它基本上说vreq 只是一个字符串,所以它没有子变量(. 之后的东西)。你应该写:

    <#if vreq == "Y" && vtype != "">
    

    【讨论】:

      猜你喜欢
      • 2012-02-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-10-19
      • 2022-01-22
      • 2022-10-15
      • 2020-10-03
      • 1970-01-01
      相关资源
      最近更新 更多