Problème avec le tutoriel Spring
Bonjour,
Je suis en train de faire le tutoriel Spring Web de Régis POUILLER. Il était assez clair jusque là, sauf qu'arrivé à la phase II-E (ici), il m'est impossible d'obtenir le résultat attendu !
Lorsque je tente d'accéder à l'url http://localhost:8080/tutoriel-web-spring/vues/bonjour, tomcat me renvoie un 404. la console donne ceci :
Code:
1 2
| juil. 03, 2014 12:06:07 PM org.springframework.web.servlet.PageNotFound noHandlerFound
AVERTISSEMENT: No mapping found for HTTP request with URI [/tutoriel-web-spring/vues/bonjour] in DispatcherServlet with name 'servlet-dispatcher' |
J'ai suivi toutes les étapes à la lettre, recommencé le tutoriel 2 fois et même été regarder les sources du projet final. Rien n'y fait. Si j'ai bien compris Tomcat, mon dispatcher ne parviendrais pas à trouver la route correspondante à /bonjour.
Si on regarde les fichiers un par un, mon dispatcher-servlet est comme ceci :
Code:
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
| <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"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
<a href="http://www.springframework.org/schema/beans/spring-beans-4.0.xsd" target="_blank">http://www.springframework.org/schem...-beans-4.0.xsd</a>
<a href="http://www.springframework.org/schema/context" target="_blank">http://www.springframework.org/schema/context</a>
<a href="http://www.springframework.org/schema/context/spring-context-4.0.xsd" target="_blank">http://www.springframework.org/schem...ontext-4.0.xsd</a>
<a href="http://www.springframework.org/schema/mvc" target="_blank">http://www.springframework.org/schema/mvc</a>
<a href="http://www.springframework.org/schema/mvc/spring-mvc.xsd" target="_blank">http://www.springframework.org/schem...spring-mvc.xsd</a>
<a href="http://www.springframework.org/schema/tx" target="_blank">http://www.springframework.org/schema/tx</a> http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
<bean id="messageSource"
class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="basename" value="classpath:messages" />
<property name="defaultEncoding" value="ISO-8859-1" />
</bean>
<context:component-scan base-package="com.developpez.rpouiller" />
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix">
<value>/vues/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
</beans> |
mon web.xml :
Code:
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
| <!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/dispatcher-servlet.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- Declaration de la servlet de Spring et de son mapping -->
<servlet>
<servlet-name>servlet-dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/dispatcher-servlet.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>servlet-dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app> |
et enfin mon BonjourController.java :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| package com.developpez.rpouiller.controller;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@Controller
@RequestMapping("/bonjour")
public class BonjourController {
@RequestMapping(method = RequestMethod.GET)
public String afficherBonjour(final ModelMap pModel) {
pModel.addAttribute("personne", "Regis");
return "bonjour";
}
} |
Comme vous pouvez le voir j'en suis même venu à laisser tel quel le code proposé par Régis...je ne comprend pas ce que j'ai pu faire mal, et je commence à avoir peur que ce tutoriel soit comme tous les autres : ça commence bien mais avec toujours un endroit mal fichu qui fait que tu ne peux plus avancer".:(
Merci d'avance pour votre aide, qui me permettra de continuer sereinement ce tutoriel.