java - For each loop in JSTL from another file -
i want way can user reply series of questions , @ end tell them mark.
so far have got this
a number of .jsps each question written within it. each page has next button taking them next question. final question links page called results.jsp needs work out if set right or wrong reply , tell them mark.
this qone.jsp
<form action="/hellospring/results" method="post"> <p> right wrapper class primitive int? </p> <input type="radio" name="radios" value="int">int<br> <input type="radio" name="radios" value="enum">enum<br> <input type="radio" name="radios" value="integer1">integer<br> <input type="radio" name="radios" value="integer2">integer<br> <input type="text" name="elc" autocomplete="off" >name<br> <input type="submit" value="next" > </form> <form><input type="button" value="back" onclick="history.go(-1);return true;"></form> </body> </html>
once clicked results.jsp
<body> <h2>result</h2> <p>good day ${elc}, scored ${a} </p> <c:foreach items="${results}" var="total" > ${total}; ${score}; ${score}; </c:foreach> <section> <p>total score: ${total}</p> </section> </body> </html>
this webcontroller.java file should deal result final question (shown above). runs if statement , depending on if "runs" add together 0 or 1 hashmap. @ point print out total of hash map show score , add together in request mappings other questions. want first 1 working.
@requestmapping(value = "/results", method = requestmethod.post) public string results(model model, httpsession session, httpservletrequest request, @requestparam string elc) { object map2 = session.getattribute("map"); hashmap<string, integer> map = (hashmap<string, integer>) map2; request.getsession().setattribute("score", "total"); if(request.getparameter("radios") != null) { if(request.getparameter("radios").equals("int")) { model.addattribute("score", 0); system.out.println("int selected answer"); } else if(request.getparameter("radios").equals("enum")) { model.addattribute("score", 0); system.out.println("enum selected answer"); } else if(request.getparameter("radios").equals("integer1")) { model.addattribute("score", 0); system.out.println("integer selected answer"); } else { system.out.println("integer selected answer"); model.addattribute("score", 1); } } homecoming "results"; }
there no real problem here if want suggest questions on front end end on wizard http://www.jquery-steps.com/examples.
if create wizard in front end end, have check question @ end in controller , send result jsp. still maintain jsp , include in each wizard part if doesn't want have bigger question.jsp file.
in scenario, next , previous button easy. score calculation easy too.
java spring jsp jstl el
No comments:
Post a Comment