Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
337 views
in Technique[技术] by (71.8m points)

java - How to add a field value in Option/Select in Thymeleaf?

I want to get a list of all of the existing Ids from a Quiz Entity from my backend/database and place that list in a Select/Option using Thymeleaf (so I can bind a Question entity to that selected Id, more specifically to bind a Question to a particular Quiz).

View Template as my latest failure, I know something is wrong:

<form action="#"
          th:action="@{/quiz/add}"
          th:object="${quiz}"
          method="post">

        <tr>
            <td>Select Quiz ID:</td>
            <td>
                <select th:field="*{id}">
                    <option value=""> -- </option>
                    <option th:value="${id}"
                            th:utext="${id}"/>
                </select>
            </td>
        </tr>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...