Win a copy of Terraform in Action this week in the Cloud forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

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

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

Please somebody help on this issue. I have tried all the combination which are suggest on help sites to over come the issue, but i am unable to get rid of the error.
Error:

org.springframework.web.servlet.tags.form.InputTag | Neither BindingResult nor plain target object for bean name 'loginForm' available as request attribute
java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'loginForm' available as request attribute
at org.springframework.web.servlet.support.BindStatus.<init>(BindStatus.java:141) ~[spring-webmvc-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getBindStatus(AbstractDataBoundFormElementTag.java:178) ~[spring-webmvc-3.1.1.RELEASE.jar:3.1.1.RELEASE]

Bean Class:

@Entity
@Table(name = "LOGIN")
public class UserVO{


// = null;
public UserVO(){

}

@Id
@Column(name = "USER_ID")
private String userId;

@Column(name = "USERNAME")
private String username;

@Column(name = "PASSWORD")
private String password;

@Column(name = "CREATED_BY")
private String creadtedBy;

// Reference to other associated class
// Getter Setter

}

Controller Class:

@Controller
@SessionAttributes("USERPREF")
public class HomeController{

@RequestMapping(value = "/login", method = RequestMethod.GET)
public ModelAndView showLoginForm(@ModelAttribute("loginForm") UserVO loginForm, BindingResult result){
return new ModelAndView("login", "loginForm", new UserVO());
}

@RequestMapping(value = "/login", method = RequestMethod.POST)
public ModelAndView processForm(ModelMap model, @Valid @ModelAttribute("loginForm") UserVO loginForm, BindingResult result, HttpSession session){
session.setMaxInactiveInterval(30);
ModelAndView view = new ModelAndView();

// Validation Code End.
if(result.hasErrors()){
view.setViewName("login");
view.addObject("loginForm", loginForm);
view.addObject("result", result);
}
else{
// some good businee ,ogic
}

return view;
}

}

JSP :
===========


<section class="col_12 column">
<div class="col_12">
<div class="left">
<p id="title">Hello This is Validation Page</p>
</div>
</div>
<div class="col_12 horizontal">
<form:form action="login.html" method="post" commandName="loginForm">
<div class="inputItem">
<label for="login_userid"><spring:message
code="login.userid" /></label>
<form:input path="userId"
title="Please provide your User Id"/>
<form:errors path="userId" cssClass="error" />
</div>

<div class="inputItem">
<label for="login_password"><spring:message
code="login.password" /></label>
<form:password path="password" title="Password is required" />
<form:errors path="password" cssClass="error" />
</div>
<input class="button" type="submit"/>
</form:form>
</div>
</section>

Spring Configuration xml
================

<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:beans="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd">

<!-- Enables the Spring MVC @Controller programming model -->
<mvc:annotation-driven />
<context:annotation-config/>


</beans:beans>


pom.xml
========

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>3.1.1.RELEASE</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>3.1.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>3.1.1.RELEASE</version>
</dependency>
<!-- Hibernate Validator Start -->
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.0.0.GA</version>
</dependency>

<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>4.0.2.GA</version>
</dependency>
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic