Jsp 用于';名称'';id'';价值';输入标签的属性

Jsp 用于';名称'';id'';价值';输入标签的属性,jsp,thymeleaf,Jsp,Thymeleaf,我在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="

我在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>

您可以尝试使用
th:with
来处理thymeleaf中的局部变量

<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>


请参阅:

谢谢,但现在我已经从我的项目中删除了thymeleaf并添加了jsp。
<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>