这是我的场景:</p>
1、在行动中,变量id是declear就像吹(TestAction.java):
…
private Integer id;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
…
2、web.xml中的配置:
…
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
<dispatcher>INCLUDE</dispatcher>
</filter-mapping>
…
<servlet>
<servlet-name>JSPSupportServlet</servlet-name>
<servlet-class>org.apache.struts2.views.JspSupportServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
…
3、在freemarker文件(test.ftl)中调用:
…
<@s.include value="/invitation/inviter"/><#-- there is no variable id in this action -->
…
<span>${id}<span>
…
4、错误信息:
Error on line 63, column 61 in WEB-INF/ftl/invitation/ test.ftl
Expecting a string, date or number here, Expression id!0 is instead a freemarker.ext.beans.ArrayModel
The problematic instruction:
----------
==> ${id} [on line 63, column 59 in WEB-INF/ftl/invitation/test.ftl]
in user-directive page [on line 1, column 1 in WEB-INF/ftl/invitation/ test.ftl]
----------
Java backtrace for programmers:
----------
freemarker.core.NonStringException: Error on line 63, column 61 in WEB-INF/ftl/invitation/ test.ftl
Expecting a string, date or number here, Expression id!0 is instead a freemarker.ext.beans.ArrayModel
at freemarker.core.Expression.getStringValue(Expression.java:126)
at freemarker.core.Expression.getStringValue(Expression.java:93)
at freemarker.core.DollarVariable.accept(DollarVariable.java:76)
at freemarker.core.Environment.visit(Environment.java:210)
我的代码有问题吗?