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 :

"mvc:view-controller" is not bound [MVC]


Sujet :

Spring Web Java

  1. #1
    Membre du Club
    Inscrit en
    Octobre 2008
    Messages
    47
    Détails du profil
    Informations forums :
    Inscription : Octobre 2008
    Messages : 47
    Points : 44
    Points
    44
    Par défaut "mvc:view-controller" is not bound
    Bonjour,

    Je cherche à faire mon premier (et dernier) "Hello World" avec spring MVC.

    Je voudrais que la home ne passe pas par un controler mais affiche la View directement grace à l'intruction mvc:view-controller

    Voici la config de mon unique dispatcher, quasiment complétement issue du template STS 2.5 de projet MVC:

    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
    <?xml version="1.0" encoding="UTF-8"?>
    <beans:beans xmlns="http://www.springframework.org/schema/mvc"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xmlns:beans="http://www.springframework.org/schema/beans"
    	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">
    
    	<!-- DispatcherServlet Context: defines this servlet's request-processing infrastructure -->
    	
    	<!-- Enables the Spring MVC @Controller programming model -->
    	<annotation-driven />
    
    	<!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources directory -->
    	<resources mapping="/resources/**" location="/resources/" />
    
    	<!-- Resolves views selected for rendering by @Controllers to .jsp resources in the /WEB-INF/views directory -->
    	<beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    		<beans:property name="prefix" value="/WEB-INF/views/" />
    		<beans:property name="suffix" value=".jsp" />
    	</beans:bean>
    	
    	<!-- Imports user-defined @Controller beans that process client requests -->
    	<beans:import resource="controllers.xml" />
    	
    		<mvc:view-controller path="home" view-name="home" />
    	
    	
    </beans:beans>
    J'ai l'erreur suivante:

    The prefix "mvc" for element "mvc:view-controller" is not bound.
    Que dois-je faire pour que l'instruction soit acceptée?

    Merci

  2. #2
    Rédacteur
    Avatar de Hikage
    Profil pro
    Inscrit en
    Mai 2004
    Messages
    1 177
    Détails du profil
    Informations personnelles :
    Âge : 40
    Localisation : Belgique

    Informations forums :
    Inscription : Mai 2004
    Messages : 1 177
    Points : 6 301
    Points
    6 301
    Par défaut
    C'est une erreur xml, tu utilise un namespace qui n'est pas déclaré :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:mvc="http://www.springframework.org/schema/mvc"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="
            http://www.springframework.org/schema/beans 
            http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
            http://www.springframework.org/schema/mvc
            http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
    Hikage
    SCJP / SCWCD & SCWSJD Certified / Spring Framework Certified
    [Personal Web] [CV]

    F.A.Q Spring Framework - Participez !

  3. #3
    Rédacteur
    Avatar de Hikage
    Profil pro
    Inscrit en
    Mai 2004
    Messages
    1 177
    Détails du profil
    Informations personnelles :
    Âge : 40
    Localisation : Belgique

    Informations forums :
    Inscription : Mai 2004
    Messages : 1 177
    Points : 6 301
    Points
    6 301
    Par défaut
    Autant pour moi, j'ai lu trop vite.

    En fait tu utilise le namespace MVC comme namespace par défault.

    Donc tu ne dois pas mettre mvc:view-controlleur mais directement :

    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
    <?xml version="1.0" encoding="UTF-8"?>
    <beans:beans xmlns="http://www.springframework.org/schema/mvc"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xmlns:beans="http://www.springframework.org/schema/beans"
    	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">
    
    	<!-- DispatcherServlet Context: defines this servlet's request-processing infrastructure -->
    	
    	<!-- Enables the Spring MVC @Controller programming model -->
    	<annotation-driven />
    
    	<!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources directory -->
    	<resources mapping="/resources/**" location="/resources/" />
    
    	<!-- Resolves views selected for rendering by @Controllers to .jsp resources in the /WEB-INF/views directory -->
    	<beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    		<beans:property name="prefix" value="/WEB-INF/views/" />
    		<beans:property name="suffix" value=".jsp" />
    	</beans:bean>
    	
    	<!-- Imports user-defined @Controller beans that process client requests -->
    	<beans:import resource="controllers.xml" />
    	
    		<view-controller path="home" view-name="home" />
    	
    	
    </beans:beans>
    Hikage
    SCJP / SCWCD & SCWSJD Certified / Spring Framework Certified
    [Personal Web] [CV]

    F.A.Q Spring Framework - Participez !

  4. #4
    Membre du Club
    Inscrit en
    Octobre 2008
    Messages
    47
    Détails du profil
    Informations forums :
    Inscription : Octobre 2008
    Messages : 47
    Points : 44
    Points
    44
    Par défaut
    oops! Merci

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. MVC (model view controler)
    Par java2dev dans le forum Général Java
    Réponses: 2
    Dernier message: 08/03/2011, 10h55
  2. [EJB2.1] Erreur not bound
    Par c+cool dans le forum Java EE
    Réponses: 9
    Dernier message: 13/01/2006, 12h11
  3. YPBINDPROC_DOMAIN: Domain not bound
    Par roger12 dans le forum Réseau
    Réponses: 2
    Dernier message: 24/10/2005, 13h25
  4. [EJB Stateless] javax.naming.NameNotFoundException: ejb not bound
    Par slymira dans le forum Java EE
    Réponses: 18
    Dernier message: 04/07/2005, 15h30

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