Bonjour,

Je rencontre une difficulté bloquante pour la création d’un formulaire.

Mon code Java :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
@RequestMapping(value = "/", method = RequestMethod.GET)
    public String home(Model model) {
        model.addAttribute("accountForm", new FormAccount());
        return "index";
    }
    @RequestMapping(value = "/", method = RequestMethod.POST)
    public String homeForm(Model model, @ModelAttribute("accountForm") FormAccount accountForm) {
        return "redirect:/";
    }
Mon code HTML :

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
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
<div class="column">
                <form action="#" th:action="@{/}" th:object="${accountForm}" method="post">
                    <!-- Champs nom -->
                    <div class="field">
                        <label class="label">Nom</label>
                        <div class="control">
                            <input class="input" type="text" placeholder="Smith" th:field="*{nom}">
                        </div>
                    </div>
 
                    <!-- Champs prénom -->
                    <div class="field">
                        <label class="label">Prénom</label>
                        <div class="control">
                            <input class="input" type="text" placeholder="Alex" th:field="*{prenom}">
                        </div>
                    </div>
 
                    <!-- Champs Email -->
                    <div class="field">
                        <label class="label">Email</label>
                        <div class="control">
                            <input class="input" type="email" placeholder="alexsmith@gmail.com" th:field="*{email}">
                        </div>
                    </div>
 
                    <!-- Champs téléphone -->
                    <div class="field">
                        <label class="label">Numéro de téléphone</label>
                        <div class="control">
                            <input class="input" type="tel" placeholder="06..." th:field="*{tel}">
                        </div>
                    </div>
 
                    <!-- Champs type de projet -->
                    <div class="field">
                        <label class="label">Type de projet</label>
                        <div class="control">
                            <input class="input" type="text" placeholder="Associatif, aide aux jeunes, etc..."
                                   th:field="*{typeProject}">
                        </div>
                    </div>
 
                    <!-- Champs description du projet -->
                    <div class="field">
                        <label class="label">Description du projet</label>
                        <div class="control">
                            <textarea class="textarea is-focused" placeholder="Mon projet consiste à [...]"
                                      th:field="*{description}"></textarea>
                        </div>
                    </div>
 
                    <!-- Validation des champs -->
                    <div class="control">
                        <button class="button is-primary">Valider</button>
                        <input type="submit" value="Create"/>
                    </div>
                </form>
            </div>

Le message d'erreur que je rencontre quand je vais sur la page :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
Caused by: java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'accountForm' available as request attribute
	at org.springframework.web.servlet.support.BindStatus.<init>(BindStatus.java:153)
	at org.springframework.web.servlet.support.RequestContext.getBindStatus(RequestContext.java:903)
	at org.thymeleaf.spring5.context.webmvc.SpringWebMvcThymeleafRequestContext.getBindStatus(SpringWebMvcThymeleafRequestContext.java:227)
	at org.thymeleaf.spring5.util.FieldUtils.getBindStatusFromParsedExpression(FieldUtils.java:306)
	at org.thymeleaf.spring5.util.FieldUtils.getBindStatus(FieldUtils.java:253)
	at org.thymeleaf.spring5.util.FieldUtils.getBindStatus(FieldUtils.java:227)
	at org.thymeleaf.spring5.processor.AbstractSpringFieldTagProcessor.doProcess(AbstractSpringFieldTagProcessor.java:174)
	at org.thymeleaf.processor.element.AbstractAttributeTagProcessor.doProcess(AbstractAttributeTagProcessor.java:74)
	... 67 more
J’ai regardé des tutoriels (surtout celui-ci : https://o7planning.org/en/11545/spri...eleaf-tutorial ), pourtant ça semble être correct, je suis ouvert à vos suggestions.