Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring 如何使用插值设置FreeMarker变量?错误:";你可以';t使用${“在这里,因为您已经处于FreeMarker表达式模式。”;?_Spring_Spring Mvc_Freemarker - Fatal编程技术网

Spring 如何使用插值设置FreeMarker变量?错误:";你可以';t使用${“在这里,因为您已经处于FreeMarker表达式模式。”;?

Spring 如何使用插值设置FreeMarker变量?错误:";你可以';t使用${“在这里,因为您已经处于FreeMarker表达式模式。”;?,spring,spring-mvc,freemarker,Spring,Spring Mvc,Freemarker,我是一个全新的FreeMarker用户,在使用此模板引擎的Spring MVC应用程序上遇到以下问题 因此,在控制器方法中,我将表示当前年份(2016年)的int放入模型中,如下所示: model.addAttribute("annoCorrente", annoCorrente); 然后,在我的FreeMarker页面中,我必须将该值赋给一个变量,因此我编写以下表达式: <#assign a = ${annoCorrente}> 为什么?如何使用从与此视图关联的模型获得的值正确

我是一个全新的FreeMarker用户,在使用此模板引擎的Spring MVC应用程序上遇到以下问题

因此,在控制器方法中,我将表示当前年份(2016年)的int放入模型中,如下所示:

model.addAttribute("annoCorrente", annoCorrente);
然后,在我的FreeMarker页面中,我必须将该值赋给一个变量,因此我编写以下表达式:

<#assign a = ${annoCorrente}>
为什么?如何使用从与此视图关联的模型获得的值正确初始化FreeMarker变量?

更改为


(或者您可以执行
,但不建议这样做)

annoCorrente
已经是一个变量。请阅读有关FreeMarker模型的详细信息。错误消息是不言自明的,只需使用
。好的,我知道它是一个变量,但如何使用它将其值分配给另一个变量?
[col. 86] You can't use "${" here as you are already in FreeMarker-expression-mode. Thus, instead of ${myExpression}, just write myExpression. (${...} is only needed where otherwise static text is expected, i.e, outside FreeMarker tags and ${...}-s.)