Bonsoir les amisvous allez bien ?
je suis débutante dans struts2 (j'ai commencé à m'y interessé depuis une semaine) mais là je suis bloquée
Voilà je vous explique mon problème, j'ai une action qui comporte plusieurs methode dont la méthode "getFilieres()" :
cette methode recupere une collection de filieres extraite de ma base de données :
le probleme c'est que dans ma page jsp les valeur des filieres ne s'affiche pas et m'indique que la liste est vide, alors que j'ai bien testé au niveau de mon action que la liste est bien remplie
voilà mes pages :
FiliereAction :
listeFilieres.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
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80 package resplan.groupes.presentation.actions; import java.util.Collection; import java.util.Iterator; import javax.servlet.http.HttpServlet; import com.opensymphony.xwork2.Action; import resplan.commun.model.groupes.Filiere; import resplan.commun.pl.BaseAction; import resplan.groupes.service.FiliereService; import resplan.groupes.service.IFiliereService; public class FiliereAction extends BaseAction { private String idFiliere; private String code; private String intitule; private Collection filieres; public String getIdFiliere() { return idFiliere; } public void setIdFiliere(String idFiliere) { this.idFiliere = idFiliere; } public String getCode() { return code; } public void setCode(String code) { this.code = code; } public String getIntitule() { return intitule; } public void setIntitule(String intitule) { this.intitule = intitule; } // Méthode d'ajout de filiere public void setFilieres(Collection filieres) { this.filieres = filieres; } public String getFilieres() { Collection<Filiere> filieres = null; try { IFiliereService service = new FiliereService(); filieres = service.getFilieres(); System.out.println("!!!!!!!!!"); for(Iterator iter = filieres.iterator();iter.hasNext();){ Filiere f = (Filiere)iter.next(); System.out.println(f.getCode()); } setFilieres(filieres); } catch (Exception ex) { ex.printStackTrace(); return Action.ERROR; } return Action.SUCCESS; } }
je crois que c'est tout<%@page import="resplan.commun.model.groupes.Filiere"%>
<%@page import="java.util.Iterator"%>
<%@page import="java.util.Collection"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!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 width="70%" border="1">
<tr>
<td>code</td>
<td>intitule</td>
</tr>
<s:if test="%{filieres.size()>0}">
<s:iterator value="filieres">
<tr>
<td> <s:property value="code" /></td>
<td><s:property value="intitule" /></td>
</tr>
</s:iterator>
</s:if>
<s:else>
Aucune filière dans la liste
</s:else>
</table>
</body>
</body>
</html>
merci d'avanc pour votre aide![]()
Partager