Je ne vois pas purquoi je ne passe pas dans mon action :
voici mon formulaire :
mon fichier de struts :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10 <html:form action="/addrecord"> lastname : <html:text property="lastname" /><br/> firstname : <html:text property="firstname" /><br/> phone : <html:text property="phone" /><br/> departement : <html:text property="departement" /><br/> <html:submit /> </html:form>mon action qui se trouve dans la package phoneBookAction :
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 <?xml version="1.0" encoding="ISO-8859-1" ?> <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.3//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_3.dtd"> <struts-config> <form-beans> <form-bean name="addRecordForm" type="phoneBookForm.AddRecordForm" /> </form-beans> <global-exceptions> </global-exceptions> <action-mappings> <action path="/listrecords" input="/index.jsp" type="phoneBookAction.ListRecordAction" scope="session"> <forward name="page" path="/index.jsp" /> <forward name="success" path="/resultlistrecord.jsp" /> </action> <action path="/addrecordredirection" type="org.apache.struts.actions.ForwardAction" parameter="/addrecord.jsp"> </action> <action path="/addrecord" name="addRecordForm" input="/addrecord.jsp" type="phoneBookAction.AddRecordAction" scope="session" validate="true"> <forward name="page" path="/addrecord.jsp" /> <forward name="success" path="/resultlistrecord.jsp" /> </action> </action-mappings> </struts-config>
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 package phoneBookAction; import java.util.HashMap; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.struts.action.Action; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import phoneBookForm.AddRecordForm; import phoneBookBo.Employee; import phoneBookBo.Personne; public class AddRecordAction extends Action{ ActionForward executeGet(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response){ return mapping.findForward("page"); } ActionForward executePost(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response){ AddRecordForm addRecordForm = (AddRecordForm) form; String lastname = addRecordForm.getLastname(); String firstname = addRecordForm.getFirstname(); String phone = addRecordForm.getPhone(); String departement = addRecordForm.getDepartement(); Employee employee = new Employee(new Personne(firstname,lastname ), phone, departement); HashMap<String, Employee> map = new HashMap(); if(request.getSession().getAttribute("map")!=null){ map = (HashMap<String, Employee>) request.getSession().getAttribute("map"); } employee.addRecord(map, employee.getPhone()); request.getSession().setAttribute("map", map); return mapping.findForward("success"); } }







Répondre avec citation





Partager