Impossible de lire une HashMap dans JSP
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 :
Code:
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%> |
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.
Voici le code controleur :
Code:
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 ); |
Code au niveau jsp :
Code:
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%>
<%} %> |
Avez-vous une idée, pouvez vous m'aider ?
Merci par avance...