2016-04-12 2 views
0

Frühling Boot-Anwendung mit Thymeleaf Ansichten ergeben Parsen mir Fehler, wenn ich versuche, wie diese in Array-Index Variable zu verwenden:Frühlings-Boot + Thymeleaf Parsing-Fehler in Schleife

<tr th:each="cdItem, stat : *{commonDataItems}">  
     <td th:text=${stat.index}>Index</td>  
     <td> <input type="text" th:field=*{commonDataItems[__${stat.index}__].value>Value</td>  
</tr> 

Diese <td th:text=${stat.index}>Index</td> Linie für Testzwecke ist und es gibt der richtige Indexwert, aber nächste Zeile <td> <input type="text" th:field=*{commonDataItems[__${stat.index}__].value>Value</td> gibt Parsing-Fehler. Fehlermeldung ist:

org.thymeleaf.exceptions.TemplateProcessingException: Could not parse as expression: "*{commonDataItems[__${stat.index}__].value" (common) 
    at org.thymeleaf.standard.expression.StandardExpressionParser.parseExpression(StandardExpressionParser.java:238) ~[thymeleaf-2.1.4.RELEASE.jar:2.1.4.RELEASE] 
    at org.thymeleaf.standard.expression.StandardExpressionParser.parseExpression(StandardExpressionParser.java:79) ~[thymeleaf-2.1.4.RELEASE.jar:2.1.4.RELEASE] 

Irgendwelche Ideen, was falsch ist?

+1

Sind Sie fehlende Anführungszeichen oder ist das nur ein Tippfehler: 'th: field = " * {commonDataItems [__ $ {stat.index} __] Wert"' –

+0

Danke, Das war's. Nicht zu stolz auf mich selbst jetzt :) Sie können das als Antwort schreiben und ich werde es akzeptieren. – JohnP

+1

Ta, du brauchst nur frische Augen :-) –

Antwort

1

Fehlende Zitate! So th:field="*{commonDataItems[__${stat.index}__].value"

:

<tr th:each="cdItem, stat : *{commonDataItems}">  
     <td th:text=${stat.index}>Index</td>  
     <td> <input type="text" th:field="*{commonDataItems[__${stat.index}__].value">Value</td>  
</tr>