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 :

Neither BindingResult nor plain target object for bean name 'command' available as request attribute


Sujet :

Spring Java

  1. #1
    Membre éclairé
    Profil pro
    Inscrit en
    Mars 2006
    Messages
    241
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Mars 2006
    Messages : 241
    Par défaut Neither BindingResult nor plain target object for bean name 'command' available as request attribute
    Bonjour,

    J'ai ce message d'erreur et je ne comprends pas d'où ça vient ?

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    Neither BindingResult nor plain target object for bean name 'command' available as request attribute
    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
    @Controller
    @RequestMapping("/connect")
    public class Connecter {
     
    	@InitBinder
    	public void initBinder(WebDataBinder dataBinder){
    		dataBinder.setRequiredFields(new String[] {"login", "password"});
    	}
     
     
    	@RequestMapping(method = RequestMethod.POST)
    	public String welcome(HttpServletRequest request, ConnectForm form,
    			BindingResult r) {
    		String page = "/produit.jsp";
     
    		if (request.getSession().getAttribute("client") == null) {
    			ConnectFormValidator validator = new ConnectFormValidator();
    			validator.validate(form, r);
    			if (!r.hasErrors()) {
    				IDAOFactory factory = DAOFactory.getInstance();
    				IClient client = factory.getDAOClient().selectClient(
    						request.getParameter("login"),
    						request.getParameter("login").toCharArray());
    				if (client != null) {
    					page = "compte.jsp";
    					request.getSession().setAttribute("client", client);
     
    				}
    			}
    		}
     
    		return page;
     
    	}
    ma page jsp est :
    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
     
    <?xml version="1.0" encoding="UTF-8" ?>
    <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
    <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    	<head>
    		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    		<title>Welcome page</title>
    	</head>
    	<body>
    		<div style="text-align:right">
        	<c:if test="${empty client}">
        	<form:form action="connect.spr" method="post" >
        		<label>Login : </label> 
        		<form:input path="login"  size="8" maxlength="8" />
        		<form:errors path="login" /><br/>
        		<label> Mot de passe :</label>
        		<form:input path="password" size="8" maxlength="8" />
        		<form:errors path="password" /><br/>
        		<input type="submit" value="se connecter"/><br/>
        	</form:form>
        	 </c:if>
        	 <div><a href="#">Mon compte</a></div>
        	</div>
     
     
     
     
    	</body>
    </html>
    mon validator :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    public void validate(ConnectForm form, Errors errors) {
    		if (form.getLogin() == null || form.getLogin().isEmpty()) {
    			errors.rejectValue("login", "required", "must not be empty");
    		} else if (form.getPassword() == null || form.getPassword().isEmpty()) {
    			errors.rejectValue("password", "required", "must not be empty");
    		}
     
    	}

  2. #2
    Membre éclairé
    Profil pro
    Inscrit en
    Mars 2006
    Messages
    241
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Mars 2006
    Messages : 241
    Par défaut Neither BindingResult nor plain target object for bean name 'loginForm' available as request attribute
    Bonjour,

    en fait jai vu que mon erreur venait du commandName qui n'est specifier (je l'ai mis dans la jsp), j'ai donc changer et mis commandName="loginForm" mais j'ai ceci :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    Neither BindingResult nor plain target object for bean name 'loginForm' available as request attribute

  3. #3
    Membre averti
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Octobre 2014
    Messages
    29
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Bénin

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

    Informations forums :
    Inscription : Octobre 2014
    Messages : 29
    Par défaut Pas très bien compris
    Citation Envoyé par fk04 Voir le message
    Bonjour,

    en fait jai vu que mon erreur venait du commandName qui n'est specifier (je l'ai mis dans la jsp), j'ai donc changer et mis commandName="loginForm" mais j'ai ceci :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    Neither BindingResult nor plain target object for bean name 'loginForm' available as request attribute
    Je n'ai pas très bien compris pouvez-vous être plus clair? Merci pour l’intérêt que vous portez à ma préocupation

Discussions similaires

  1. Réponses: 4
    Dernier message: 10/12/2014, 20h37
  2. Réponses: 1
    Dernier message: 07/03/2013, 13h18
  3. Réponses: 9
    Dernier message: 05/06/2012, 09h39
  4. Réponses: 1
    Dernier message: 31/12/2011, 01h17
  5. Erreur "Neither BindingResult nor plain target object"
    Par daydream123 dans le forum Spring
    Réponses: 0
    Dernier message: 11/09/2011, 15h10

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