我在jsp文件中有一个片段,如下所示
<c:forEach var="question" items="${questionList }">
<p>{{ question.question }}</p>
<c:forEach var="answer" items="${question.answerList }">
<input type="radio" name="${question.id }" id="${answer.id }" value="${answer.sequence }">
<label for="${answer.id }">${answer.answer }</label>
</c:forEach>
</c:forEach>
现在我使用百里香模板,我不知道如何在百里香中实施它。特别是,我不知道如何获得name
的{{1}} attr,
input
答案 0 :(得分:1)
您可以尝试使用th:with
来处理百里香的局部变量,
<div th:with="questionObj=${questionList}">
<div th:each="answer: ${questionObj}">
<input type="radio" th:name="${questionObj.id}"
th:id="${answer.id}" th:value="${answer.sequence}">
<label th:text="${answer.answer}"></label>
</div>
</div>