Bonjour à tous,

Je suis débutant "Spring", je cherche à adapter ce tutoriel (Page +-7)à mon projet.

Ma question est la suivante:

A la page 7-3 diapo j'ai pas bien compris ce:
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
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<html><head><title>formulaire Ajout</title> </head >
<body><h3>Formulaire Ajouter un membre </h3>
<!-- ?????????????????? -->
<form:form commandName ="commandAjout">
<!-- ?????????????????? -->
<table>
<tr>
<td>Nouveau Membre</ td>
<td><form:input path ="nouveauMembre" /></td>
<%-- Show errors for name field --%>
<td><form:errors path="nouveauMembre" /></td >
</tr>
<tr>
<td colspan="3"><input type="submit" value="Envoyer" /></td>
</tr>
</table>
</form:form>
</body ></html>
A la page 6-4 on dit:"Il faut indiquer la vue qui contiendra le formulaire
Il faut déclarer le nom et la classe de l’objet Command
qui contiendra les données du formulaire
"

Dans mon application j'utilise mon objet Participant, rien de particulier nom, prenom, adresse ect ...

Mon erreur est la suivante:
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
10 sept. 2010 21:12:03 org.springframework.web.servlet.tags.RequestContextAwareTag doStartTag
GRAVE: Neither BindingResult nor plain target object for bean name 'participant' available as request attribute
java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'participant' available as request attribute
        at org.springframework.web.servlet.support.BindStatus.<init>(BindStatus.java:142)
        at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getBindStatus(AbstractDataBoundFormElementTag.java:176)
        at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getPropertyPath(AbstractDataBoundFormElementTag.java:196)
        at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getName(AbstractDataBoundFormElementTag.java:147)
        at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.autogenerateId(AbstractDataBoundFormElementTag.java:134)
        at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.writeDefaultAttributes(AbstractDataBoundFormElementTag.java:123)
        at org.springframework.web.servlet.tags.form.AbstractHtmlElementTag.writeDefaultAttributes(AbstractHtmlElementTag.java:379)
        at org.springframework.web.servlet.tags.form.InputTag.writeTagContent(InputTag.java:139)
        at org.springframework.web.servlet.tags.form.AbstractFormTag.doStartTagInternal(AbstractFormTag.java:90)
        at org.springframework.web.servlet.tags.RequestContextAwareTag.doStartTag(RequestContextAwareTag.java:77)
        at org.apache.jsp.inscription_jsp._jspx_meth_form_005finput_005f0(inscription_jsp.java:332)
        at org.apache.jsp.inscription_jsp._jspx_meth_form_005fform_005f0(inscription_jsp.java:230)
        at org.apache.jsp.inscription_jsp._jspService(inscription_jsp.java:106)
        at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
        at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
        at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
        at java.lang.Thread.run(Thread.java:619)
J'ai un souci lorsque j'appel mon formulaire, ceci ne lui plait pas =>
Code : Sélectionner tout - Visualiser dans une fenêtre à part
<td valign="top" align="left"><form:input path="nom" /></td>
Pourtant j'ai fait attention à l'ensemble du tutoriel

Voici mon dispatcher-servlet.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
38
39
40
41
42
<?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:tx="http://www.springframework.org/schema/tx"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
 
    <bean class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping"/>
 
    <bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
        <property name="mappings">
            <props>
                <prop key="inscription.htm">InscriptionController</prop>
            </props>
        </property>
    </bean>
 
    <!-- Les controlleur de l'applications -->
    <bean name="InscriptionController" class="be.rtbf.appl.controller.InscriptionController">
        <property name="implParticipantDao" ref="implParticipantDao"/>
        <property name="formView">
            <value>inscription</value>
        </property>
        <property name="commandName" value="participant"/>
    </bean>
 
    <!-- les Views -->
    <bean class="org.springframework.web.servlet.view.XmlViewResolver ">
        <property name="location">
            <value>/WEB-INF/jsp/vues.xml</value>
        </property >
    </bean>
    <!--
    <bean id="viewResolver"
          class="org.springframework.web.servlet.view.InternalResourceViewResolver"
          p:prefix="/WEB-INF/"
          p:suffix=".jsp" />
    -->
</beans>
Voici mon formulaire:
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
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/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=UTF-8">
        <title>Nouveaux Utilisateur</title>
        <link href="menu.css" rel="stylesheet"  type="text/css" />
 
        <!-- CODE JAVASCRIPT -->
        <script src="Javascript/formulaireDynamique.js" language="Javascript" />
        <script type="text/javascript">
        </script>
        <!-- CODE JAVASCRIPT -->
    </head>
    <body>
        <!-- Menu -->
        <h2>Inscription</h2>
        <form:form commandName="participant" onsubmit="return verifFormulaireInscritpion()">
            <input type="hidden" name="event" id="event" value="user">
            <table border="0">
                <tr>
                    <td valign="top" align="left">Nom ?</td>
                    <td width="20px"><form:input path="mail"/></td>
                    <td valign="top" align="left"><form:input path="nom" /></td>
                </tr>
                <tr>
                    <td valign="top" align="left">Prénom</td>
                    <td width="20px"></td>
                    <td valign="top" align="left"><form:input path="prenom" /><p></p></td>
                </tr>
                <tr>
                    <td valign="top" align="left">Login</td>
                    <td width="20px"></td>
                    <td valign="top" align="left"><form:input path="login" /></td>
                </tr>
                <tr>
                    <td valign="top" align="left">Mots de passe</td>
                    <td width="20px"></td>
                    <td valign="top" align="left"><form:password path="mp" /></td>
                </tr>
                <tr>
                    <td valign="top" align="left">Confirmer mots de passe</td>
                    <td width="20px"></td>
                    <td valign="top" align="left"><form:password path="mp2" onblur="verifMp()"/><p></p></td>
                </tr>
                <tr>
                    <td valign="top" align="left">Mail (RTBF)</td>
                    <td width="20px"></td>
                    <td width="200px" valign="top" align="left"><form:input path="mail" onblur="bonmail()"/></td>
                </tr>
                <tr>
                    <td valign="top" align="left">Bureaux</td>
                    <td width="20px"></td>
                    <td valign="top" align="left"><form:input path="bureau" /></td>
                </tr>
                <tr>
                    <td valign="top" align="left">Téléphone (Bureaux)</td>
                    <td width="20px"></td>
                    <td valign="top" align="left"><form:input path="telephone" onblur="isNum(telephone)"/></td>
                </tr>
                <tr>
                    <td><h5><b>(Tous les champs sont obligatoire)</b></h5></td>
                    <td width="20px"></td>
                    <td><input type="submit" value="Enregistrer" name="envoyer" /><input type="reset" value="Annuler" name="annuler" /></td>
                </tr>
            </table>
        </form:form>
Mon 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
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package be.rtbf.appl.controller;
 
import be.rtbf.appl.concours.Participant;
import be.rtbf.appl.concours.dao.ImplParticipantDao;
import java.net.BindException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.SimpleFormController;
 
/** 
 *
 * @author Administrateur
 */
public class InscriptionController extends SimpleFormController {
 
    private ImplParticipantDao implParticipantDao;
 
    public ImplParticipantDao getImplParticipantDao() {
        return implParticipantDao;
    }
 
    public void setImplParticipantDao(ImplParticipantDao implParticipantDao) {
        this.implParticipantDao = implParticipantDao;
    }
 
    @Override
    protected Object formBackingObject(HttpServletRequest request) {
        return new Participant();
    }
 
    protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response,
        Object participantIn, BindException errors) throws Exception {
 
        Participant participant =(Participant)participantIn;
        implParticipantDao.addParticipant(participant);
        return new ModelAndView("confirmation", "participant", participant);
        /*                       Nom de la vue*/
    }
}
Voila je pense que toute l'équipe est au complet.


Merci