0

Iam developing a web application with free marker template using Struts2 tag libs. I have a map in the request object with attribute name as "namesToBeUsed"

How to assign it to a variable in ftl using struts2 tag?

Iam getting below error if I assign like this <@sftl.set name="namesToBeUsed" value='${Request["namesToBeUsed"]}'/>

Expecting a string, date or number here, Expression Request["namesToBeUsed"] is instead a freemarker.template.SimpleHash

Can any one help me? Thanks in advance.

4

1 回答 1

0

应该:

<@sftl.set name="namesToBeUsed" value=Request["namesToBeUsed"] />

因为'${whateverExpression}'进行字符串插值,因此必须将表达式值转换为字符串。因此,在 FreeMarker 标记中,只需输入表达式,周围没有任何额外的语法。

于 2012-04-05T18:14:26.977 回答