Вот моя сцена:
1 、 В действии переменная id объявлена как удар (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 message Сообщение об ошибке:
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)
что-то не так с моим кодом?