Bonjour,
Je suis confronté à un problème, j'essaye d'affiché ce que j'ai dans un hashmap mais impossible.
J'ai l'erreur suivante :
J'ai bien compris que mon erreur se situe au niveau des ligne 23 à 25, mais la j’avoue que je sèche parce que quand je test au niveau de mon controleur cela fonctionne nickel.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10 ne erreur s'est produite à la ligne: 23 dans le fichier jsp: /WEB-INF/content/showDetailsGroupAbs.jsp The type of the expression must be an array type but it resolved to Object 20: Iterator<String> it = listAbs.keySet().iterator(); 21: while(it.hasNext()){ 22: String sKey = it.next(); 23: String sProduct = listAbs.get(sKey)[0]; 24: String sPrice = listAbs.get(sKey)[1]; 25: String heure = listAbs.get(sKey)[2]; %> 26: <%= "ID : "+sKey+", Nom : "+sProduct+", Prenom : "+sPrice+", heure : "+heure%>
Voici le code controleur :
Code au niveau jsp :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14 int grpId =Integer.parseInt(request.getParameter("id")); Groupe grp = GroupeDAO.retrieveById(grpId); Map<String,String[]> e = EtudiantDAO.getAllByGrpAbs(grp); Iterator<String> it = e.keySet().iterator(); while(it.hasNext()){ String sKey = it.next(); String sProduct = e.get(sKey)[0]; String sPrice = e.get(sKey)[1]; String heure = e.get(sKey)[2]; System.out.println("ID : "+sKey+", Nom : "+sProduct+", Prenom : "+sPrice+", heure : "+heure); } request.setAttribute("listAbs",e );
Avez-vous une idée, pouvez vous m'aider ?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 <%@ page import="java.util.*"%> <%@ page import="java.util.Iterator"%> <%@ page import="fr.noteEtudiant.Bdd.*"%> <jsp:useBean id="listAbs" class="java.util.HashMap" scope="request"/> <% Iterator<String> it = listAbs.keySet().iterator(); while(it.hasNext()){ String sKey = it.next(); String sProduct = listAbs.get(sKey)[0]; String sPrice = listAbs.get(sKey)[1]; String heure = listAbs.get(sKey)[2]; %> <%= "ID : "+sKey+", Nom : "+sProduct+", Prenom : "+sPrice+", heure : "+heure%> <%} %>
Merci par avance...
Partager