• 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:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

spring form submission

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all, any body please help me...,,please

I am trying to make this work since 1 day, i dont know where is wrong..

I don't have any clue why it is giving this below error:

java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'address' available as request attribute
========================================================================
1).Home.jsp used for submission

<%@taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<html>
<body bgcolor="yellow">
<form:form action="login.htm" method="post" commandName="address">
<spring:message code="Home.state" ></spring:message>
<form:input path="state"/><br/>
<spring:message code="Home.country"></spring:message>
<form:input path="country"/><br/>
<input type="submit"/>
</form:form>
</body>
</html>
===========================================================================
"Test-servlet.xml" is my spring application context file
----------------
<?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: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.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">

<bean id="simpleUrlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mappings">
<props>
<prop key="/JSP/login.htm">usercontroller</prop>
</props>
</property>
</bean>

<bean id="address" class="com.spring.address.Address"/>

<bean id="usercontroller" class="com.spring.controller.UserController">

<property name="commandName" value="address"/>
<property name="commandClass" value="com.spring.address.Address"/>

<property name="formView" value="Home" />
<property name="successView" value="Results" />

<!-- <property name="address" ref="addr"/> -->

</bean>

<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/JSP/"></property>
<property name="suffix" value=".jsp"></property>
</bean>

</beans>

===========================================================================UserController.java my controller class:

public class UserController extends SimpleFormController {



private UserController(){
System.out.println("Enter in the UserController Constructor..");
setCommandClass(Address.class);
setCommandName("address");
}

protected Object formBackingObject(HttpServletRequest request) throws Exception {
Address address = new Address();
return address;
}

protected ModelAndView onSubmit(Object command){
System.out.println("Enter in the onSubmit method..");
Address address = (Address)command;

//return new ModelAndView(getSuccessView());
ModelAndView mav = new ModelAndView(getSuccessView());
mav.addObject("address", address);
return mav;
}
}

===========================================================================
Address.java is my Command class ,POJO

public class Address implements Serializable {
private String state;
private String country;

public void setState(String state) {
this.state = state;
}
public void setCountry(String country) {
this.country = country;
}
public String getState() {
return state;
}
public String getCountry() {
return country;
}

public Address() {

}

}
[ April 16, 2008: Message edited by: sri vas ]
 
Oh the stink of it! Smell my tiny ad!
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic