Bonjour tout le monde
Je suis dans le meme probleme que dans cette discussion, et je suis debutant sur ce framework struts.
J'ai utilisé le tag <display-tag:table ,pour afficher les noms,j'utilise struts1,Hibernate.
Voilà ma page jsp:
Voilà Ma class:
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 <%@page contentType="text/html" pageEncoding="UTF-8"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <%@taglib uri="http://displaytag.sf.net" prefix="display" %> <%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%> <%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%> <%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Liste des personnes</title> <link href="css/style.css" rel="stylesheet" type="text/css" /> </head> <body> <display:table export="true" id="data" name="sessionScope.persForm.personsList" requestURI="/persAction.do" pagesize="5" > <display:column property="nom" title="NOM" sortable="true"/> <display:column property="prenom" title="PRENOM" sortable="true"/> <display:column property="username" title="UserName" sortable="true"/> <display:setProperty name="export.excel.filename" value="ActorDetails.xls"/> <display:setProperty name="export.pdf.filename" value="ActorDetails.pdf"/> <display:setProperty name="export.pdf" value="true" /> </display:table> </body> </html>
Voilà Voilà mon ActionForm:
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103 public class Personne { private Long id; private String nom; private String prenom; private String username; private String password; private Date date_naissance; public Personne() { } public Personne(Long id,String nom, String prenom, String username,String password,Date date_naissance) { this.id = id; this.nom = nom; this.prenom = prenom; this.username = username; this.password = password; this.date_naissance = date_naissance; } public ArrayList loadData() { ArrayList userList = new ArrayList(); Session session = HibernateUtil.getSessionFactory().openSession();//getCurrentSession(); Transaction tx = null; List result = new ArrayList(); Object u=null; Object[] tmp =new Object[0]; try { tx = session.beginTransaction(); //log.debug("Session Ouverte"); Query q = session.createQuery( " select username, password,nom, prenom " + " from User " ); result = q.list(); /*for (Iterator iterator = result.iterator(); iterator.hasNext();) { Object o = (Object) iterator.next(); Object[] tmp = (Object[]) o; for (int i = 0; i < tmp.length; i++) { userList.add(tmp[i]); } }*/ for(int i =0;i<result.size();i++) { //nbreExams=0; u=(Object)result.get(i); tmp = (Object[])u; for (int index = 0; index < tmp.length; index++) { userList.add(tmp[i]); } } System.out.println("afficheTaille:"+userList.size()); System.out.println("afficheTaille:"+userList); tx.commit(); } catch(HibernateException he){ if (tx!=null) tx.rollback(); throw he; } finally { //log.debug("Session Fermée"); session.close(); } return userList; } public String getNom() { return nom; } public String getPrenom() { return prenom; } public Long getId() { return id; } public String getUsername() { return username; } public String getPassword() { return password; } }
Voilà mon Action :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13 public class personListForm extends ActionForm { private ArrayList<Personne> personsList; public ArrayList<Personne> getPersonsList() { return personsList; } public void setPersonsList(ArrayList<Personne> personsList) { this.personsList = personsList; } }
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 public class peronListAction extends Action{ private final static String SUCCESS = "success"; @SuppressWarnings("unchecked") public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { personListForm persForm = (personListForm) form; Personne persData = new Personne(); persForm.setPersonsList(persData.loadData()); //request.setAttribute("beanData",mesDonnees); //System.out.println("affiche:"+mesDonnees); return mapping.findForward(SUCCESS); } }
Voilà L'erreur:
Au secours,si quelque peut m'aider dans ce sens ou qu'il peut me filer un tuto bien claire qui pourrait me sortir de cette obscurité?org.apache.jasper.JasperException: javax.servlet.ServletException: javax.servlet.jsp.JspException: Exception: [.LookupUtil] Error looking up property "nom" in object type "java.lang.String". Cause: Unknown property 'nom'
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:536)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:410)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1085)
org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProcessor.java:263)
org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:398)
org.apache.struts.tiles.TilesRequestProcessor.processForwardConfig(TilesRequestProcessor.java:318)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:241)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
Partager