D'abord les trucs suivants :
1 2 3 4 5
| <?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2_2.dtd"> |
Puis la balise <web-app></web-app> dans laquelle tu commence par mettre ce qui concerne la servlet :
1 2 3 4 5 6 7 8 9 10 11 12 13
| <servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>application</param-name>
<param-value>ressource.ApplicationRessources</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet> |
Le truc "ressource.ApplicationRessources" c'est pour déclarer un .properties avec les chaines de caractères que j'ai référencé dedans...
puis le servlet-mapping :
1 2 3 4
| <servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping> |
juste pour dire que ce qui est en .do c'est des actions 
Puis vient la balise permettant de définir ta page d'acceuil.... tu peux en mettre plusieurs : au ca ou s'il trouve pas la première il t'acffichera la deuxieme ou la troisieme si a deuxieme est introuvable etc.... Cette balise c'est la balise <welcome-file-list></welcome-file-list> :
1 2 3
| <welcome-file-list>
<welcome-file>/jsp/logon.jsp</welcome-file>
</welcome-file-list> |
Et apres tu définis les taglib si tu en as utilisé dans tes jsp :
1 2 3 4
| <taglib>
<taglib-uri>/WEB-INF/struts-template.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-template.tld</taglib-location>
</taglib> |
<taglib-location> : chemin ou sont physiquement les .tld dans tes fichiers de projet
<taglib-uri> : uri que tu utilise pour spécifier que t'utilise des taglibs dans les pages jsp (je ne pense pas être très claire parce que je vois pas comment formuler clairement ce que je veux dire) En gros dans la page jsp tu mets :
<%@ taglib uri="/WEB-INF/struts-template.tld" prefix="template" %>
et cet uri de la jsp(uri="/WEB-INF/struts-template.tld") est celle que tu mets dans ta balise <taglib-uri> du web.xml. => c'est le mapping des fichiers .tld
Voila l'exemple d'un fichier web.xml en entier...si ca peut te servir 
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
| <?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
<web-app>
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>application</param-name>
<param-value>ressource.ApplicationRessources</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>/jsp/logon.jsp</welcome-file>
</welcome-file-list>
<taglib>
<taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-html.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-html.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-logic.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-template.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-template.tld</taglib-location>
</taglib>
</web-app> |
Anne
Partager