自由标记中的子字符串不起作用

时间:2014-02-13 11:01:45

标签: java solr freemarker

我正在尝试编写一个函数,它可以获取存储在变量中的字符串的子字符串。

我做了以下

  <#global summary_s = getSummarySubstring(activeItem, "44","")>


  <#function getSummarySubstring item summaryId>

        <#assign Summary = helper.getLinkedItems(item,summaryId,"")>

        <#assign SubSummary = ${Summary?substring(0,140)}>

        <#return SubSummary >

  </#function> 

我收到了一条freemarker错误说:

 Caused by: freemarker.core.ParseException: Encountered "{" at line 111, column 36 in 
  remoteIndexing_555_16.                                              
  Was expecting one of:
  "in" ...
   ">" ...
   <EMPTY_DIRECTIVE_END> ...
   "." ...
  "[" ...
  "(" ...
   "?" ...
  "!" ...
   <TERMINATING_EXCLAM> ...
   "??" ...
   "+" ...
    "-" ...
   "*" ...
   "/" ...
   "%" ...
   "!=" ...
   "=" ...
   "==" ...
   ">=" ...
   <ESCAPED_GTE> ...
   ">" ...

  <STRING_LITERAL> ...

任何人都可以帮忙吗?

1 个答案:

答案 0 :(得分:1)

请勿使用${...}

ie:<#assign SubSummary = Summary.substring(0,140)>

${...}用于打印到输出流