IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Spring Web Java Discussion :

spring hello world [Débutant(e)]


Sujet :

Spring Web Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre confirmé
    Profil pro
    Inscrit en
    Février 2007
    Messages
    88
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2007
    Messages : 88
    Par défaut spring hello world
    Bonjour tout le monde,
    je suis nouveau en j2ee, j'ai créer un projet j2ee avec eclips europa j'ai ajouter les .jar de Spring-2.5 j'ai suivi un tutoriel pour créer et configurer le spring MVC, j'ai fais toutes les confs normalement, à l'exécution tout ce passe bien la page index.html qui se trouve dans (WEB-INF/index.html) s'affiche, dans laquelle j'ai mets un lien pour ouvrir une autre page home.jsp qui se trouve dans (WEB-INF/jsp/home.jsp) et qui affiche "Hello world" mais la ça ne marche elle ne s'affiche pas????!!!!
    voici mes fichiers

    web.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <web-app id="WebApp_ID" version="2.4"
    xmlns="http://java.sun.com/xml/ns/j2ee" xmlnssi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

    <display-name>projetSpring</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>

    <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/springcontext-data.xml,/WEB-INF/spring-views.xml</param-value>
    </context-param>

    <!-- CONFIG DispatcherServlet -->
    <servlet>
    <servlet-name>springsample</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
    <servlet-name>springsample</servlet-name>
    <url-pattern>*.htm</url-pattern>
    </servlet-mapping>

    <!-- CONFIG Chargeur de contexte (ContextLoader) -->
    <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    </web-app>
    ----------------------------------------------------------------------
    Springcontext.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlnssi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">

    <!-- Déclaration du PropertyPlaceholderConfigurer -->
    <bean
    class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="locations">
    <list>
    <value>classpath:/com/projetSpring/dao/db.properties
    </value>
    </list>
    </property>
    </bean>

    <!-- Déclaration de la DATASOURCES -->
    <bean id="dataSource"
    class="org.springframework.jdbc.datasource.DriverManagerDataSource"
    destroy-method="close">
    <property name="driverClassName" value="${db.driver}" />
    <property name="url" value="${db.url}" />
    <property name="username" value="${db.username}" />
    <property name="password" value="${db.password}" />
    </bean>

    <bean id="hibernateProperties"
    class="org.springframework.beans.factory.config.PropertiesFactoryBean">
    <property name="properties">
    <props>
    <prop key="hibernate.dialect">
    org.hibernate.dialect.MySQLDialect
    </prop>
    <prop key="hibernate.show_sql">true</prop>
    </props>
    </property>
    </bean>

    <bean id="sessionFactory"
    class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
    <property name="annotatedClasses">
    <list>
    <value>com.projetSpring.domaine.Employe
    </value>
    </list>
    </property>
    <property name="hibernateProperties">
    <ref bean="hibernateProperties" />
    </property>
    <property name="dataSource">
    <ref bean="dataSource" />
    </property>
    </bean>

    <bean id="jdbcExceptionTranslator"
    class="org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator">
    <property name="dataSource">
    <ref bean="dataSource" />
    </property>
    </bean>

    <bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
    <property name="sessionFactory">
    <ref bean="sessionFactory" />
    </property>
    <property name="jdbcExceptionTranslator">
    <ref bean="jdbcExceptionTranslator" />
    </property>
    </bean>

    <!-- Injection dans notre HibernateTemplate de notre DAO -->
    <bean id="employeDAO" class="com.projetSpring.dao.EmployeDAO">
    <property name="hibernateTemplate">
    <ref bean="hibernateTemplate" />
    </property>
    </bean>
    </beans>
    ------------------------------------------------------------------------
    servlet-context.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlnssi="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/schem...-beans-2.5.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schem...ontext-2.5.xsd
    ">
    <context:annotation-config />

    <context:component-scan
    base-package="com.projetSpring.Controleur">
    </context:component-scan>

    <!-- Handler Mapping pour annotations -->
    <bean
    class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">
    </bean>
    <bean
    class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
    </bean>

    <bean
    class="org.springframework.web.servlet.view.XmlViewResolver">
    <property name="location">
    <value>/WEB-INF/spring-views.xml</value>
    </property>
    </bean>

    <!-- View Resolver : Toutes les vues sont des JSP-->
    <bean id="viewResolver"
    class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="viewClass"
    value="org.springframework.web.servlet.view.JstlView">
    </property>
    <property name="prefix">
    <value>/WEB-INF/jsp/</value>
    </property>
    <property name="suffix">
    <value>.jsp</value>
    </property>
    </bean>

    <!-- Load messages -->
    <bean id="messageSource"
    class="org.springframework.context.support.ResourceBundleMessageSource">
    <property name="basename" value="errors" />
    </bean>

    </beans>

    ------------------------------------------------------

    index.html

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlnssi="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/schem...-beans-2.5.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schem...ontext-2.5.xsd
    ">
    <context:annotation-config />

    <context:component-scan
    base-package="com.projetSpring.Controleur">
    </context:component-scan>

    <!-- Handler Mapping pour annotations -->
    <bean
    class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">
    </bean>
    <bean
    class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
    </bean>

    <bean
    class="org.springframework.web.servlet.view.XmlViewResolver">
    <property name="location">
    <value>/WEB-INF/spring-views.xml</value>
    </property>
    </bean>

    <!-- View Resolver : Toutes les vues sont des JSP-->
    <bean id="viewResolver"
    class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="viewClass"
    value="org.springframework.web.servlet.view.JstlView">
    </property>
    <property name="prefix">
    <value>/WEB-INF/jsp/</value>
    </property>
    <property name="suffix">
    <value>.jsp</value>
    </property>
    </bean>

    <!-- Load messages -->
    <bean id="messageSource"
    class="org.springframework.context.support.ResourceBundleMessageSource">
    <property name="basename" value="errors" />
    </bean>

    </beans>
    ------------------------------------------------------------

    home.jsp

    <%@ page contentType="text/html"%>

    <html>
    <head>
    <title>Firm Team</title>
    </head>
    <body>
    <h2>Hello!</h2>

    <a href='home.htm'>Clickez pour aller vers home</a>

    </body>
    </html>
    -----------------------------------------------
    mais à l'exécution j'ai ces erreurs :

    03-03-2010 23:47:42:703 28750 DEBUG org.springframework.web.servlet.DispatcherServlet - Testing handler map [org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping@bfbbe3] in DispatcherServlet with name 'springsample'
    03-03-2010 23:47:42:718 28765 DEBUG org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping - Looking up handler for [/Hello.htm]
    03-03-2010 23:47:42:718 28765 DEBUG org.springframework.web.servlet.DispatcherServlet - No handler found in getLastModified
    03-03-2010 23:47:42:718 28765 DEBUG org.springframework.web.servlet.DispatcherServlet - DispatcherServlet with name 'springsample' received request for [/projetSpring/Hello.htm]
    03-03-2010 23:47:42:812 28859 DEBUG org.springframework.util.ClassUtils - Class [javax.faces.context.FacesContext] or one of its dependencies is not present: java.lang.ClassNotFoundException: javax.faces.context.FacesContext
    03-03-2010 23:47:42:828 28875 DEBUG org.springframework.web.servlet.DispatcherServlet - Bound request context to thread: org.apache.catalina.connector.RequestFacade@552a2b
    03-03-2010 23:47:42:828 28875 DEBUG org.springframework.web.servlet.DispatcherServlet - Testing handler map [org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping@bfbbe3] in DispatcherServlet with name 'springsample'
    03-03-2010 23:47:42:828 28875 DEBUG org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping - Looking up handler for [/Hello.htm]
    03-03-2010 23:47:42:828 28875 WARN org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/projetSpring/Hello.htm] in DispatcherServlet with name 'springsample'
    03-03-2010 23:47:42:828 28875 DEBUG org.springframework.web.servlet.DispatcherServlet - Cleared thread-bound request context: org.apache.catalina.connector.RequestFacade@552a2b
    03-03-2010 23:47:42:828 28875 DEBUG org.springframework.web.servlet.DispatcherServlet - Successfully completed request
    03-03-2010 23:47:42:828 28875 DEBUG org.springframework.web.context.support.XmlWebApplicationContext - Publishing event in context [org.springframework.web.context.support.XmlWebApplicationContext@10c3a08]: ServletRequestHandledEvent: url=[/projetSpring/Hello.htm]; client=[127.0.0.1]; method=[GET]; servlet=[springsample]; session=[null]; user=[null]; time=[110ms]; status=[OK]
    03-03-2010 23:47:42:828 28875 DEBUG org.springframework.web.context.support.XmlWebApplicationContext - Publishing event in context [org.springframework.web.context.support.XmlWebApplicationContext@15bdc50]: ServletRequestHandledEvent: url=[/projetSpring/Hello.htm]; client=[127.0.0.1]; method=[GET]; servlet=[springsample]; session=[null]; user=[null]; time=[110ms]; status=[OK]


    ----------------------------------------
    votre aide me serai présieuse
    Merci pour votre aide

  2. #2
    Membre très actif
    Profil pro
    Inscrit en
    Octobre 2007
    Messages
    134
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Octobre 2007
    Messages : 134
    Par défaut
    Utilise les options de l'éditeur pour rédiger un sujet sur le forum.

    Exemple

    Cela encouragera la lecture de ton problème.

    Cordialement C-bolo

Discussions similaires

  1. [Framework] Mon premier "Hello World" avec spring
    Par Eric_beauvais dans le forum Spring
    Réponses: 5
    Dernier message: 29/07/2013, 07h42
  2. [MVC] Spring MVC, un "simple" hello world
    Par pigpen dans le forum Spring Web
    Réponses: 1
    Dernier message: 08/07/2011, 09h45
  3. hello world
    Par floorfille dans le forum CORBA
    Réponses: 3
    Dernier message: 26/07/2007, 14h34
  4. [Débutant] hello world jsp tomcat
    Par RENAULT dans le forum Tomcat et TomEE
    Réponses: 24
    Dernier message: 13/05/2004, 16h29
  5. [STRUTS] hello world, bonjour le monde
    Par Celina dans le forum Struts 1
    Réponses: 3
    Dernier message: 19/04/2004, 15h41

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo