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 :

Etat HTTP 404 - /WEB-INF/views/product/create.jsp


Sujet :

Spring Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre confirmé
    Profil pro
    Inscrit en
    Novembre 2005
    Messages
    136
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Novembre 2005
    Messages : 136
    Par défaut Etat HTTP 404 - /WEB-INF/views/product/create.jsp
    Bonjour
    je suis entrain de réaliser une application spring mvc , j ' ai un problème avec le contrôleur . quand j appuie sur lien create il me dirige pas sur bon url et j'ai un message d'erreur "Etat HTTP 404 - /WEB-INF/views/product/create.jsp"

    voici 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
     
     
    @Controller
    @RequestMapping(value="/product")
    public class ProductEditController {
     
    	@Autowired ProductRepository productRepository;	
     
    	public ModelAndView prepareModelAndView(Product product){
    		ModelAndView mv = new ModelAndView("edit"); /*jsp*/
    		mv.addObject("id", product.getId());
    		mv.addObject("product", product);
    		return mv;
    	}
     
    	@RequestMapping("/create")
    	public ModelAndView createProduct(){		
    		return prepareModelAndView(new Product());
    	}
     
    	@RequestMapping("/edit")
    	public ModelAndView updateProduct(@RequestParam ("id") Long id){
    		Product product = productRepository.findById(id);		
    		return prepareModelAndView(product);
    	}
     
    	@RequestMapping(value="/editsubmit",method=RequestMethod.POST)
    	public ModelAndView addProductOnSubmit(@Valid @ModelAttribute("Product") Product product, BindingResult bindingResult){
    		if(bindingResult.hasErrors()){
    			return new ModelAndView("edit","product", product);
    		}
     
    		if(product.getId() !=  null){
    			productRepository.create(product);
    		}else{
    			productRepository.update(product);
    		}
    		return new ModelAndView("redirect:/product/edit");
    	}
     
    	@RequestMapping("/delete")
    	public ModelAndView deleteProduct(@RequestParam ("id") Long id){
    		Product product = productRepository.findById(id);
    		if(product != null)
    			productRepository.delete(id);		
    		return new ModelAndView("redirect:/listproduct"); /*jsp*/
    	}
     
     
    }
    voici home page
    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
     
     !DOCTYPE html >
     
    <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
    <%@taglib uri="http://www.springframework.org/tags" prefix="spring" %>
    <%@taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
    <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
     
     
    <html lang="fr">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <meta charset="utf-8">
    <title>Ecommerce project</title>
    </head>
    <body>
      <form action="" method="post">
    	<li><a href="<c:url value='/product/create'/>"> Create </a></li>
    	<li><a href="productlist">Lister</a></li>
     
     </form>	 
    </body>
    </html>
    voilci le 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
    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>ECommerceProject</display-name>
     
     
     
      <servlet>
        <servlet-name>dispatcher</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>  
        <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>
    voici le dispatcher

    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.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="be.ecommerceproject.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>

  2. #2
    Modérateur
    Avatar de MasterMbg
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Octobre 2011
    Messages
    719
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Congo-Kinshasa

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Octobre 2011
    Messages : 719
    Par défaut
    Bonjour,
    je suis apprenant dans java ee (10 jours seulement de travail) je ne sais pas si je vais t'être d'une aide particulière. lol
    Au fait, ce code d'erreur 404 m'était renvoyé lorsque j'avais un souci dans le web.xml de mon projet dans lequel je déclare mes servlets. Surtout, le problème venait du renseignement du context d'une servlet dans la balise . Il faut soigner à bien renseigner le contexte (package) dans lequel se trouve votre servlet en le terminant bien sur par un point, suivi du nom de la servlet en question.
    Plus tu apprends sérieusement, plus tu te rapproches d'un savoir noble. Une chose est certaine, les difficultés ne s'écarteront de ton chemin...

    Tu es nouveau dans le développement Android, la page des COURS est là pour te faciliter la vie
    Tu peux trouver la réponse à ta question dans la FAQ
    Retrouvez mon tutoriel sur la consommation des services web SOAP
    Pense à voter positivement en appuyant sur en bas à droite de la réponse qui t'a donné une piste de solution.

  3. #3
    Rédacteur/Modérateur
    Avatar de andry.aime
    Homme Profil pro
    Inscrit en
    Septembre 2007
    Messages
    8 391
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Ile Maurice

    Informations forums :
    Inscription : Septembre 2007
    Messages : 8 391
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    <a href="/product/create">
    A+.

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

    Informations forums :
    Inscription : Novembre 2005
    Messages : 136
    Par défaut
    Citation Envoyé par andry.aime Voir le message
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    <a href="/product/create">
    A+.
    j 'ai change le code , j' ai toujours le même message d erreur

    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
     
     
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
     
     !DOCTYPE html >
     
    <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
    <%@taglib uri="http://www.springframework.org/tags" prefix="spring" %>
    <%@taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
    <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
     
     
    <html lang="fr">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <meta charset="utf-8">
    <title>Ecommerce project</title>
    </head>
    <body>
      <form action="" method="post">
    	<li><a href="<product/create "> Create </a></li>
    	<li><a href="productlist">Lister</a></li>
     
     </form>	 
    </body>
    </html>

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

    Informations forums :
    Inscription : Novembre 2005
    Messages : 136
    Par défaut
    Citation Envoyé par kanebody Voir le message
    j 'ai change le code , j' ai toujours le même message d erreur

    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
     
     
     
     !DOCTYPE html >
     
    <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
    <%@taglib uri="http://www.springframework.org/tags" prefix="spring" %>
    <%@taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
    <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
     
     
    <html lang="fr">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <meta charset="utf-8">
    <title>Ecommerce project</title>
    </head>
    <body>
      <form action="" method="post">
    	<li><a href="<product/create "> Create </a></li>
    	<li><a href="productlist">Lister</a></li>
     
     </form>	 
    </body>
    </html>
    je suis toujours à la recherche de solution merci

  6. #6
    Rédacteur/Modérateur
    Avatar de andry.aime
    Homme Profil pro
    Inscrit en
    Septembre 2007
    Messages
    8 391
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Ile Maurice

    Informations forums :
    Inscription : Septembre 2007
    Messages : 8 391
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    <a href="<product/create ">
    attention, tu as un "<" à la place de "/" dans l'attribut href.

    A+.

Discussions similaires

  1. [MVC] Erreur : Etat HTTP 404 - /learning/create
    Par kanebody dans le forum Spring Web
    Réponses: 2
    Dernier message: 15/07/2014, 17h37
  2. Etat HTTP 404 - /personnel/WEB-INF/vues/feuille1.jsp
    Par hoor3in dans le forum Struts 1
    Réponses: 2
    Dernier message: 19/07/2007, 11h42
  3. [Tomcat]Etat HTTP 404, fichier web.xml inéxistant
    Par subzero82 dans le forum Tomcat et TomEE
    Réponses: 12
    Dernier message: 09/05/2006, 09h10
  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