File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Other Application Frameworks and the fly likes spring form submission Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "spring form submission" Watch "spring form submission" New topic
Author

spring form submission

sri vas
Greenhorn

Joined: Apr 16, 2008
Posts: 1
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 ]
 
 
subject: spring form submission