Contents
  1. 1. Background
  2. 2. Error Info
  3. 3. Solutions
  4. 4. Reasons

Background

When I use the FreeMarker to generate text files, occurs an error: Failed to “?eval” string.

1
<#assign dataFromConfigJson = columnMapping.formComponentDataFromConfig?eval>

Error Info

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
FreeMarker template error:
Failed to "?eval" string with this error:

---begin-message---
Syntax error in ?eval-ed string in line 1, column 175:
Encountered "}", but was expecting one of:
<STRING_LITERAL>
<RAW_STRING>
"false"
"true"
<INTEGER>
<DECIMAL>
"."
".."
<DOT_DOT_LESS>
"..*"
"?"
"??"
"+"
"-"
"!"
","
"["
"]"
"("
"{"
<ID>
<TERMINATING_EXCLAM>
"+"
"-"
---end-message---

The failing expression:
==> columnMapping.formComponentDataFromConfig?eval [in template "templates/demo\\html\\test.ftl" at line 208, column 41]

----
FTL stack trace ("~" means nesting-related):
- Failed at: #assign dataFromConfigJson = columnMa... [in template "templates/demo\\html\\test.ftl" in macro "generateFormItems" at line 208, column 11]
- Reached through: @generateFormItems type="search" [in template "templates/demo\\html\\test.ftl" at line 582, column 7]
----

Solutions

Corrects the JSON string of the field of data that passed to the FreeMarker Template object.

Reasons

The JSON string is invalid.

Contents
  1. 1. Background
  2. 2. Error Info
  3. 3. Solutions
  4. 4. Reasons