bonjour
j'ai un problème lors de la conversion d'une valeur string a une valeur Long voila le code
le probleme sur cette ligneCode:
1
2
3
4
5
6
7
8
9
10
11 if(request.getParameter("var").equals("ajqcm")) { // aqf.setIdQcm(Long.parseLong(request.getParameter("idQcm"))); aqf.setIdQcm(dI.getIdQcm()); //aqf.setIdQuestion(Long.valueOf(request.getParameter("id_quest"))); aqf.setIdQuestion(Long.parseLong(request.getParameter("id_quest"))); aqf.setDuree(Integer.parseInt(request.getParameter("duree"))); aqf.setNb_quest(Integer.parseInt(request.getParameter("nb_quest"))+1); dI.addQuestionToQcm(aqf.getIdQuestion(), aqf.getIdQcm()); return map.findForward("vueDefinirQcm"); }
voila le code de la page jspCode:aqf.setIdQuestion(Long.parseLong(request.getParameter("id_quest")));
l'erreurCode:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50 <html:form action="AjoutQcm.do" method="POST"> Matière : <html:select name="aqf" property="idMatiere" > <html:optionsCollection name="aqf" property="lesMat" label="matiere" value="idMatiere" /> </html:select> <html:hidden name="aqf" property="idNiveau" ></html:hidden> <html:submit value="Afficher" property="affich_connaiss"></html:submit> Choisir une connaissance : <html:select name="aqf" property="idConnaissance" > <html:optionsCollection name="aqf" property="lesConn" label="connaissance" value="idConnaissance"/> </html:select> <html:hidden name="aqf" property="idQcm"/> <html:hidden name="aqf" property="duree"/> <html:hidden name="aqf" property="nb_quest"/> <html:submit value="Afficher" property="affich_Question"></html:submit> <p> </p> <table width="315" border="0" align="right"> <tr> <td width="184" bgcolor="#90B6FF">.Durée du test : </td> <td width="121"><span class="Style5"> <bean:write name="aqf" property="duree" /> seconds</span></td> </tr> <tr> <td bgcolor="#90B6FF">.Nombre de question : </td> <td><span class="Style5"><bean:write name="aqf" property="nb_quest" /></span></td> </tr> </table> <table border="1" > <tr bgcolor="#90B6FF"><td>Question</td> <td>Type question</td> <td>Nombre bonnes réponses</td> </tr> <logic:iterate id="qt" name="aqf" property="lesQuestions"> <tr> <td><bean:write name="qt" property="question" /></td> <td><bean:write name="qt" property="type" /></td> <td><bean:write name="qt" property="nbBonneRep" /></td> <td><a href='AjoutQcm.do?nb_quest=<bean:write name="aqf" property="nb_quest"/> &duree=<bean:write name="aqf" property="duree"/> &id_quest=<bean:write name="qt" property="idQuestion"/> &var=ajqcm'>Choisir</a></td> </tr> </logic:iterate> </table> </html:form>
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 javax.servlet.ServletException: For input string: "3 " org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:523) org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:421) org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224) org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194) org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414) javax.servlet.http.HttpServlet.service(HttpServlet.java:689) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) cause mère java.lang.NumberFormatException: For input string: "3 " java.lang.NumberFormatException.forInputString(NumberFormatException.java:48) java.lang.Long.parseLong(Long.java:412) java.lang.Long.parseLong(Long.java:461) qcm.web.actions.AjoutQcmAction.execute(AjoutQcmAction.java:81) org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419) org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224) org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194) org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414) javax.servlet.http.HttpServlet.service(HttpServlet.java:689)