I am developing a questionnaire application with spring MVC. I have the form with 30 questions and 30 radio buttons. When the user submit the form I have to get the user answers from the request I have three decision.
Inside a loop call request.getParameter() 30 times
:
public class QuestionBank { private List<Question> question; .... } <form:form action="question.html" modelAttribute="QuestionList" > <c:forEach items="${QuestionList.question}" var="q" varStatus="status"> ... <input type="radio" name="question[${status.index}].useranswer" value="1" /> <input type="radio" name="question[${status.index}].useranswer" value="2" /> ... </div> </c:forEach> <input type="submit" value="submit" /> </form:form>
process the list inside controller
Use the Ajax submission (create a json format of answers)
From this three Which the recommended and fast processing ?
@ModelAttribute
. This is all based on speculation, as I don't know internally the different paths Spring might possibly take.