bonjour
je suis entrain de faire un programme en java/ struts pour afficher une table dans la base de donnée oracle 9:
il me donne cette erreur :
voici code source de appli : merci de votre service et ton aide, je suis bloqué;type Rapport d'état
message No action instance for path /Appli could be created
description Le serveur a rencontré une erreur interne (No action instance for path /Appli could be created) qui l'a empêché de satisfaire la requête.
voici fichier strut-config.xml :
voici le controleur :
Code xml : 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 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd"> <struts-config> <data-sources> <data-source key = "xxxStruts2" type="org.apache.commons.dbcp.BasicDataSource"> <set-property property="driverClassName" value="oracle.jdbc.driver.OracleDriver" /> <set-property property="url" value="jdbc:oracle:thin:@xxxx:basedonee" /> <set-property property="username" value="*****" /> <set-property property="password" value="******" /> <set-property property="minCount" value="3" /> <set-property property="validationQuery" value="select 1 from dual" /> </data-source> </data-sources> <form-beans> <form-bean name="ApplicationListAction" type="action.ApplicationListAction"> </form-bean> </form-beans> <action-mappings type="org.apache.struts.action.ActionMapping"> <action path="/Appli" type="action.ApplicationListAction" name="applicationListAction" scope="request" input="/applicationListe.jsp"> <forward name="success" path="/ApplicationListe.jsp" redirect="false" /> </action> </action-mappings> </struts-config>
et voici le package model :
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127 package action; import model.Application; import java.io.IOException; import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.apache.struts.action.ActionError; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.Action; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.apache.struts.actions.DispatchAction; import javax.sql.DataSource; import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.ArrayList; public class ApplicationListAction extends Action { private ArrayList getApplications () { Application application=null; ArrayList applications = new ArrayList(); Connection conn =null; Statement stmt =null; ResultSet rs=null; ServletContext context=servlet.getServletContext(); DataSource dataSource = (DataSource) context.getAttribute(Action.DATA_SOURCE_KEY); try { conn = dataSource.getConnection(); stmt = conn.createStatement(); rs = stmt.executeQuery("select * from ARIANE.applications " ); while ( rs.next() ) { application = new Application(); application.setNom(rs.getString("nom")); application.setEnvDeveloppement(rs.getString("envDeveloppement")); application.setEnvRecette(rs.getString("envRecette")); application.setEnvProduction(rs.getString("envProduction")); applications.add(application); } } catch (SQLException e) { System.err.println(e.getMessage()); } finally { if (rs != null) { try { rs.close(); } catch (SQLException sqle) { System.err.println(sqle.getMessage()); } rs = null; } if (stmt != null) { try { stmt.close(); } catch (SQLException sqle) { System.err.println(sqle.getMessage()); } stmt = null; } if (conn != null) { try { conn.close(); } catch (SQLException sqle) { System.err.println(sqle.getMessage()); } conn = null; } } return applications; } public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { ArrayList applications = null; applications = getApplications(); request.setAttribute("applications", applications); return mapping.findForward("success"); } }
et le fichier index.jsp est :
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 public class Application { private String nom; private String envDeveloppement; private String envRecette; private String envProduction; public String getEnvDeveloppement() { return envDeveloppement; } public void setEnvDeveloppement(String envDeveloppement) { this.envDeveloppement = envDeveloppement; } public String getEnvProduction() { return envProduction; } public void setEnvProduction(String envProduction) { this.envProduction = envProduction; } public String getEnvRecette() { return envRecette; } public void setEnvRecette(String envRecette) { this.envRecette = envRecette; } public String getNom() { return nom; } public void setNom(String nom) { this.nom = nom; } }
merci pour ton aide
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8 <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <html> <head> <title>Ariane</title> <link rel="stylesheet" href="/css/styles.css" type="text/css"> </head> <c:redirect url="http://localhost:8080/Application/Appli.do"/> </html>
Partager