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 :

Erreur : Etat HTTP 404 - /learning/create


Sujet :

Spring Web 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 Erreur : Etat HTTP 404 - /learning/create
    Bonjour,

    J'essaie de mettre en place un projet JEE avec Spring MVC mais j'ai le message d'erreur suivant :
    Etat HTTP 404 - /learning/create

    type Rapport d''état

    message /learning/create

    description La ressource demandée n''est pas disponible.
    Voici ce que je fais

    Le contrôleur :
    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
    package com.learning.controller;
     
    import javax.validation.Valid;
     
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.stereotype.Controller;
    import org.springframework.validation.BindingResult;
    import org.springframework.web.bind.annotation.ModelAttribute;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.RequestMethod;
    import org.springframework.web.bind.annotation.RequestParam;
    import org.springframework.web.portlet.ModelAndView;
     
    import com.learning.model.Lieu;
    import com.learning.model.Trainer;
    import com.learning.repository.LieuRepository;
     
    @Controller
    @RequestMapping("/learning")
    public class LieuController {
        @Autowired
        private LieuRepository lieuRepository;
     
        private ModelAndView prepareModelAndView(Lieu lieu ) {
            ModelAndView mv = new ModelAndView("edit");
            mv.addObject("id", lieu.getId());
            mv.addObject("lieu", lieu ); 
            return mv; 
        }
        @RequestMapping("/create")
        public ModelAndView lieuCreate() {
             return prepareModelAndView(new Lieu());     
        }
     
    @RequestMapping("/edit")
    public ModelAndView lieuEdit (@RequestParam("id")long id) {
        Lieu lieu= (Lieu)lieuRepository.findById(id);
        return prepareModelAndView(lieu);
    }
     
     
    @RequestMapping(value="/addOnsubmit",method=RequestMethod.POST)
    public ModelAndView LieuAddSubmit( @Valid  @ModelAttribute Lieu lieu,@Valid  @ModelAttribute Trainer trainer, BindingResult bindingResult){
     
        if (bindingResult.hasErrors()){
            return new ModelAndView ("edit","lieu",lieu);
        }
     
        if(lieu.getId()!=null) {
           lieuRepository.merge(lieu);
        } else {
            lieuRepository.persist(lieu);
        }
     
        return new ModelAndView("redirect:/displaylieu");
    }   
     
    @RequestMapping("/delete")
    public ModelAndView lieuDelete(@RequestParam("id")long idlieu) {
        Lieu lieu = (Lieu)lieuRepository.findById(idlieu);
        if (lieu!= null ){
           lieuRepository.delete(idlieu);
        }
        return new ModelAndView("redirect:/displaylieu");
    }
     
    }
    web.xml :
    Code xml : 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
    <?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>Learning_Spring00</display-name>
      <servlet>
        <servlet-name>dispatcher</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
          <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>/WEB-INF/dispacher-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>/WEB-INF/classes/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>
    home page(web-inf/views/index.jsp) :
    Code html : 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
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
        pageEncoding="ISO-8859-1"%>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
    <%@ taglib uri="http://www.springframework.org/tags/form"  prefix="form"%>    
    <!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>
      <form:form action=" " method="">
        <div>
         <ul>
           <li><a href="/learning/create">Ajout</a></li>
           <li><a href="<c:url value='/learning/create'/>"> Créer </a></li>
           <li><a href="<c:url value='/learning/edit'/>"> add </a></li>
         </ul>            
      </div>
      </form:form>
    </body>
    </html>
    web-inf/views/edit.jsp :
    Code html : 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
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"pageEncoding="ISO-8859-1"%>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
    <%@ taglib uri="http://www.springframework.org/tags/form"  prefix="form"%>
    <!DOCTYPE html >
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>place</title>
    </head>
    <body>
      <form:form action='<%=response.encodeURL("/addOnsubmit")%>'modelAttribute=lieu" method="post">
            <form:hidden path="id"/>
            <label>Name</label>   <form:input path="name" />       <form:errors path="name" /><br>
            <label>Street</label>    <form:input path="street" />        <form:errors path="street" /><br>
            <input type="submit"value="<c:choose><c:when test="${lieu.id==null}">Add </c:when><c:otherwise>Edit</c:otherwise></c:choose>"/>
        </form:form>
    </body>
    </body>
    </html>
    Quelqu'un saurait-il m'indiquer comment résoudre ce problème ?

    merci pour votre aide

  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
    salut,
    peux-tu nous montrer le contenu de ton fichier et 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
    Les voici :

    applicationContext.xml
    Code xml : 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
    <?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="com.learning.repository" />
     
     
        <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="org.postgresql.Driver" />-->
                   <!-- <property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/> -->
                    <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>
    dispacher-servlet.xml
    Code xml : 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
    <?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.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">
     
     
        <context:annotation-config />
        <context:component-scan base-package="com.learning.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>
    Merci pour ton aide.

Discussions similaires

  1. Etat HTTP 404 - /WEB-INF/views/product/create.jsp
    Par kanebody dans le forum Spring
    Réponses: 11
    Dernier message: 10/01/2014, 01h04
  2. TOMCAT 6.0.18 ERREUR ETAT HTTP 404
    Par hajer_baccouch dans le forum Tomcat et TomEE
    Réponses: 3
    Dernier message: 20/05/2011, 16h56
  3. Erreur Etat HTTP 404
    Par tcharles dans le forum Tomcat et TomEE
    Réponses: 2
    Dernier message: 25/03/2008, 21h43
  4. Tomcat - Servlet - Erreur "Etat HTTP 404"
    Par Doumeasse38 dans le forum Tomcat et TomEE
    Réponses: 16
    Dernier message: 03/05/2006, 13h51
  5. [eclipse] [tomcat] etat http 404
    Par semaj_james dans le forum Eclipse Java
    Réponses: 3
    Dernier message: 30/03/2006, 21h03

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