在我的应用程序中,我正在使用一组问题创建页面。这些问题来自数据库。现在我想将每个问题的用户选择的答案插入到数据库中,因为我需要用户选择答案的值。我在viewQuestionList.jsp页面中写了下面的代码。
<form method='post' action='/OnlineExam/SubmitExam'>
<div>
<h1>Question Paper</h1>
<c:choose>
<c:when test='${QuestionList == null || empty QuestionList}'>
No Questions available at this time
</c:when>
<c:otherwise>
<c:forEach items="${QuestionList}" var="curQuestion">
<p>${curQuestion.getQuestion()}</p>
<input type="radio" value="a" name="${curQuestion.getQuestionId()}">${curQuestion.getOption1()}<br>
<input type="radio" value="b" name="${curQuestion.getQuestionId()}">${curQuestion.getOption2()}<br>
<input type="radio" value="c" name="${curQuestion.getQuestionId()}">${curQuestion.getOption3()}<br>
<input type="radio" value="d" name="${curQuestion.getQuestionId()}">${curQuestion.getOption4()}<br>
</c:forEach>
<button type="SUBMIT" id="btnSubmit" name="btnSubmit">SUBMIT</button>
</c:otherwise>
</c:choose>
</div>
</form>