Bonjour,
Je tente désespérément de mettre en place un projet J2EE avec le framework Spring. Je tente ici d'afficher simplement la page d'accueil du site, mais j'ai une erreur 404 :
Etat HTTP 404 - /Toto/
type Rapport d'état
message /Toto/
description La ressource demandée (/Toto/) n'est pas disponible.
Apache Tomcat/6.0.32
Voici ce que j'ai fait :
1. Création via Eclipse d'un nouveau "Dynamic Web Project" portant le nom "Toto"
2. Importation dans le projet des bibliothèques Spring
3. Création d'un DispatcherServlet pour implémenter MVC 2 portant le nom "TotoControleur".
4. Création d'un contrôleur de navigation :
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 package fr.toto.controleurs; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; @Controller public class ControleurNavigation { @RequestMapping("**/rechercher.smvc") public String AfficherRechercher() { return "Rechercher"; } @RequestMapping("**/compte.smvc") public String AfficherCompte() { return "Compte"; } }
5. Création des pages JSP "index.jsp", "compte.jsp", "rechercher.jsp" qui ne contiennent que du HTML.
6. Création du fichier de configuration de mon dispatcher "ExchangeGamesControleur-servlet.xml" :
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 <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"> <!-- Recherche du controlleur par annotation --> <context:component-scan base-package="fr.toto.controleurs" /> <!-- Sélecteur de vues --> <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/pages/" /> <property name="suffix" value=".jsp" /> </bean> </beans>
Pour finir, voici le contenu du fichier "web.xml" :
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 <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"> <display-name>toto</display-name> <welcome-file-list> <welcome-file>index.html</welcome-file> <welcome-file>index.htm</welcome-file> <welcome-file>index.jsp</welcome-file> <welcome-file>default.html</welcome-file> <welcome-file>default.htm</welcome-file> <welcome-file>default.jsp</welcome-file> </welcome-file-list> <servlet> <description>controleur de facade</description> <display-name>TotoControleur</display-name> <servlet-name>TotoControleur</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>TotoControleur</servlet-name> <url-pattern>*.smvc</url-pattern> </servlet-mapping> </web-app>
Quand je lance le projet, je n'ai pas d'erreurs ni d'avertissements de la part de Tomcat.
J'utilise Spring dans se version 3.0.7 et Tomcat dans sa version 6.
Merci d'avance pour votre aide !
Partager