2017-09-01 239 views
1

我希望有人可以帮我解决我与Thymeleaf的问题。Thymeleaf拼接预处理:

这种情况是我需要用thymeleaf做预处理,第一个是正确的,但是在第一次预处理中,我需要从模型中获得另一个字段,但是当我在另一个预处理中添加字段preprocessinf时,我一个类型的错误

无法解析为表达式: “$ {规则[”

如果我这样做,它工作正常

rules[__${row.index}__].propertiesValues[] 

未能插入其他预处理

rules[__${row.index}__].propertiesValues[__${rules[__${row.index}__].bookingRuleDescriptor.propertyDescriptors[__${iter.index}__].name}__] 

我希望你能帮助我。

谢谢!

回答

0

只有一个预处理过程。由于不匹配__,您会得到该错误。例如,第一次尝试来预处理:

propertiesValues[__${rules[__${row.index}__] 

它试图评估的表达式是__${rules[__,这不是有效的thymeleaf表达。

你的选项有:

如果未在次使用这种表达

1):场,你不应该做反正预处理。你可以简单地使用:

${rules[row.index].propertiesValues[rules[row.index].bookingRuleDescriptor.propertyDescriptors[iter.index].name]} 

2)如果您在使用第这样的:场,你必须使用第:有手之前评估你的一些表情。例如:

<th:block th:with="i=${row.index}, j=${rules[row.index].bookingRuleDescriptor.propertyDescriptors[iter.index].name}"> 
    <input type="text" th:field="*{rules[__${i}__].propertiesValues['__${j}__']}" /> 
</th:block> 
+0

非常感谢! @Metroids,我已经实现的第二个解决方案,一切都很完美! :) 未知如何创建和分配百里香叶中的变量。感谢您的宝贵帮助。 – H3ct0r