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 Java Discussion :

La ressource demandée n''est pas disponible :etat http 404


Sujet :

Spring Java

  1. #1
    Membre du Club
    Profil pro
    Inscrit en
    Novembre 2005
    Messages
    136
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Novembre 2005
    Messages : 136
    Points : 57
    Points
    57
    Par défaut La ressource demandée n''est pas disponible :etat http 404
    Bonjour à tous
    je suis entrain de creer une application spring mvc mais j' ai problème de la configuration(applicationcontext;xml ,dispatcher-servlet.xml et web.xml)
    quand je lance mon application il trouve pas le fichier home.jsp
    voici le message etat http 404
    home.jsp
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
     
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
        pageEncoding="ISO-8859-1"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Insert title here</title>
    </head>
    <body>
     
    </body>
    </html>
    controlleur
    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
     
    package be.jpa.controller;
     
    import org.springframework.stereotype.Controller;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.RequestMethod;
     
    @Controller
    public class IndexController {
     
        @RequestMapping(value={"/","/ home"}, method = RequestMethod.GET)
        public String homePage(){
            System.out.println(" Spring MVC");
            return" home";
        }
    }
    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
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
     
    <?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_3_0.xsd" version="3.0">
      <display-name>bbstore</display-name>
      <servlet>
        <servlet-name>dispatcher</servlet-name>
          <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
          <init-param>
             <param-name>dispatcher-servlet</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>dispatcher</servlet-name>
        <url-pattern>/*</url-pattern>
      </servlet-mapping>
     
      <!-- le chargeur du contexte de l'application -->
      <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
      </listener>
      <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:/applicationContext.xml</param-value>
      </context-param>
     
        <filter>
        <filter-name>JpaFilter</filter-name>
        <filter-class>org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter</filter-class>
      </filter>
      <filter-mapping>
        <filter-name>JpaFilter</filter-name>
        <url-pattern>/*</url-pattern>
      </filter-mapping>
     
    </web-app>
    dispatcher-servlet
    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
     
    <?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:mvc="http://www.springframework.org/schema/mvc"
        xmlns:context="http://www.springframework.org/schema/context"
        xsi:schemaLocation="
            http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
            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">
     
     
        <context:annotation-config />
            <context:component-scan base-package="be.jpa.controller"> 
         </context:component-scan>
     
    	<bean id="viewResolver"	class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    		<property name="prefix">
    			<value>/WEB-INF/views/</value>
    		</property>
    		<property name="suffix">
    			<value>.jsp</value>
    		</property>
    	</bean>
     
    </beans>
    applicationcontext
    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
     
    <?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:p="http://www.springframework.org/schema/p"
    xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context"
    xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:util="http://www.springframework.org/schema/util"
     
    xsi:schemaLocation="
    http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
    http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd
    http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.2.xsd
    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
    http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.2.xsd">
     
        <context:annotation-config />
     
        <context:component-scan base-package="be.jpa" />
     
     
        <aop:config proxy-target-class="true" />
     
    <!--     <context:property-placeholder ignore-unresolvable="false" location="classpath:/config.properties,classpath:/secret.properties"/> -->
     
     
        <!-- for injecting value in application context.xml -->
        <bean id="propertyPlaceholder" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
            <property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE"/>
            <property name="ignoreResourceNotFound" value="true"/>
            <property name="locations">
                <list>
                    <value>classpath:/jdbc.properties</value>
                </list>
            </property>
        </bean>
     
        <bean id="entityManagerFactory"   class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
            <property name="persistenceUnitName" value="Connection" />
            <property name="dataSource" ref="dataSource"/>  
     
            <property name="jpaVendorAdapter">
                <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter" />
            </property>
            <property name="jpaProperties">
     
                <!-- set extra properties here, e.g. for Hibernate: -->
                <props>
    <!--            <prop key="hibernate.connection.url">${DB.url}</prop>
                    <prop key="hibernate.connection.username">${DB.userName}</prop>
                    <prop key="hibernate.connection.password">${DB.password}</prop>-->
                    <prop key="hibernate.showsql">true</prop>
                 </props>
            </property>
     
        </bean>
     
        <!-- database -->
         <bean id="dataSource" class="org.apache.commons.dbcp.datasources.SharedPoolDataSource"
            destroy-method="close">
            <property name="connectionPoolDataSource">
                <bean
                    class="org.apache.commons.dbcp.cpdsadapter.DriverAdapterCPDS">
                   <!-- <property name="driver" value="net.sf.log4jdbc.DriverSpy" /> use this to trace jdbc BOTH JPA AND JdbcTemplate--> 
                    <property name="driver" value="com.mysql.jdbc.Driver" />
                    <property name="url" value="${DB.url}" />
                    <property name="user" value="${DB.userName}" />
                    <property name="password" value="${DB.password}" />
                    <property name="maxActive" value="0" />
                    <property name="maxIdle" value="0" />
                    <property name="poolPreparedStatements" value="true" />
                </bean>
            </property>
            <property name="maxWait" value="60000" />
            <property name="defaultAutoCommit" value="false" />
            <property name="defaultReadOnly" value="false" />
        </bean>
     
     
     
     
        <!-- Transaction manager for a single JPA EntityManagerFactory (alternative to JTA) -->
        <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"
              p:entityManagerFactory-ref="entityManagerFactory" />
        <tx:annotation-driven />
     
     
     
        <!-- Configure the multipart resolver (image upload) -->
        <bean id="multipartResolver"
        class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
            <!-- one of the properties available; the maximum file size in bytes (10mb
            here) -->
            <property name="maxUploadSize" value="10000000" />
            <property name="maxInMemorySize" value="10000000" />
        </bean>
     
     
    </beans>
    merci

  2. #2
    Membre chevronné Avatar de jeffray03
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Juillet 2008
    Messages
    1 501
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Allemagne

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Juillet 2008
    Messages : 1 501
    Points : 2 120
    Points
    2 120
    Par défaut
    t´as pas mis un espace de trop a home : " home"; ?

    eric

  3. #3
    Membre du Club
    Profil pro
    Inscrit en
    Novembre 2005
    Messages
    136
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Novembre 2005
    Messages : 136
    Points : 57
    Points
    57
    Par défaut
    Citation Envoyé par jeffray03 Voir le message
    t´as pas mis un espace de trop a home : " home"; ?

    eric
    j' enlève l' espace de trop a home j ai le même message d'erreur

  4. #4
    Membre confirmé
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Octobre 2008
    Messages
    380
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Octobre 2008
    Messages : 380
    Points : 480
    Points
    480
    Par défaut
    Bonjour,

    Est ce que tu as enlevé les espaces aux deux endroits: dans RequestMapping et dans le méthode homePage ?

    A+.

  5. #5
    Membre du Club
    Profil pro
    Inscrit en
    Novembre 2005
    Messages
    136
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Novembre 2005
    Messages : 136
    Points : 57
    Points
    57
    Par défaut
    Citation Envoyé par eric39 Voir le message
    Bonjour,

    Est ce que tu as enlevé les espaces aux deux endroits: dans RequestMapping et dans le méthode homePage ?

    A+.
    oui j' ai enlevé dans la méthode et RequestMapping mais avec System.out.println(" Spring MVC"); il affiche dans le console

  6. #6
    Membre du Club
    Profil pro
    Inscrit en
    Novembre 2005
    Messages
    136
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Novembre 2005
    Messages : 136
    Points : 57
    Points
    57
    Par défaut
    Citation Envoyé par kanebody Voir le message
    oui j' ai enlevé dans la méthode et RequestMapping mais avec System.out.println(" Spring MVC"); il affiche dans le console
    merci ça marche

Discussions similaires

  1. Etat HTTP 404 - La ressource demandée n'est pas disponible
    Par af.zakaria dans le forum Tomcat et TomEE
    Réponses: 6
    Dernier message: 20/03/2014, 14h48
  2. Etat HTTP 404: La ressource demandée n''est pas disponible
    Par Marc_27 dans le forum Tomcat et TomEE
    Réponses: 0
    Dernier message: 28/04/2013, 23h26
  3. Etat http 404:la ressource demandé n'est pas disponible
    Par amine_smi dans le forum Servlets/JSP
    Réponses: 2
    Dernier message: 04/04/2009, 20h07
  4. La ressource demandée n'est pas disponible.
    Par info_plus dans le forum Tomcat et TomEE
    Réponses: 1
    Dernier message: 03/04/2008, 17h49
  5. Erreur 404 - La ressource demandée (/**/) n'est pas disponible.
    Par Rom1984 dans le forum Tomcat et TomEE
    Réponses: 9
    Dernier message: 20/03/2008, 16h06

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