Bonjour,
J'ai crée une liste. Je voudrais bien afficher tous les éléments.
Le code de la liste:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9 public static List<Produit> selectAll(){ List<Produit> lp=new ArrayList<Produit>(); lp.add(new Produit(1, "fraise", 1.5f)); lp.add(new Produit(2, "pomme", 1.5f)); lp.add(new Produit(3, "orange", 1.8f)); lp.add(new Produit(4, "peche", 1.7f)); return lp; }
Le code où j'essaie afficher les éléments:
Mais j'obtiens le résultat suivant: [pojo.Produit@1c1b6c3, pojo.Produit@c5e102, pojo.Produit@1378b53, pojo.Produit@19c3036]
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
16
17
18
19
20
21
22
23 <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Insert title here</title> </head> <body> <table border='1'><tr><th>Id</th><th>N</th><th>P</th></tr> <% List<Produit> p = (List<Produit>) request.getAttribute("catalogue"); out.println("<tr><td>" + Produitd.selectAll() + "</td></tr>"); %> </table> </body> </html>
Comment faire?
Merci!!!
Partager