• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

BindingResult nor plain target object for bean name 'usersuccess' available as request attribute"

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello....
I am trying to develop web application using spring mvc framework which contain 2 form.
1. user form 2. usersuccess form
i am using 2 controllers for these two forms. i am able to disblay my first form but when i click on submit button on user form i got following error
"java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'usersuccess' available as request attribute"

please help

my code:

User.java

ackage com.vaannila.domain;

public class User {

private String name;
private String password;


public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}


UserSuccess.java


package com.vaannila.domain;

public class UserSuccess {

protected String amtinfo;
protected String amtwithdraw;


public String getAmtInfo() {
return amtinfo;
}
public void setAmtInfo(String amtinfo) {
this.amtinfo = amtinfo;
}
public String getAmtWithdraw() {
return amtwithdraw;
}
public void setAmtWithdraw(String amtwithdraw) {
this.amtwithdraw = amtwithdraw;
}
}

UserController.java
package com.vaannila.web;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.SimpleFormController;
import com.vaannila.domain.User;


@SuppressWarnings("deprecation")
public class UserController extends SimpleFormController {


User user = new User();
public UserController() {
setCommandClass(User.class);
setCommandName("user");
}


@Override
protected ModelAndView onSubmit(Object command) throws Exception {
User user = (User) command;
return new ModelAndView("userSuccess","user",user);
}

}

UserSuccesController.java

package com.vaannila.web;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.SimpleFormController;


import com.vaannila.domain.UserSuccess;


@SuppressWarnings("deprecation")
public class UserSuccessController extends SimpleFormController {



UserSuccess usersuccess = new UserSuccess();
public UserSuccessController(){
setCommandClass(UserSuccess.class);
setCommandName("usersuccess");
}

@Override
public ModelAndView onSubmit(Object commandName) throws Exception {
UserSuccess usersuccess = (UserSuccess) commandName;
return new ModelAndView("logout","usersuccess",usersuccess);
}

}

dispactcher-servlet.xml

<?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:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">

<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver"
p:prefix="/WEB-INF/jsp/"
p:suffix=".jsp" />

<bean id="messageSource"
class="org.springframework.context.support.ReloadableResourceBundleMessageSource"
p:basename="/WEB-INF/messages" />

<bean id="userValidator"
class="com.vaannila.validator.UserValidator" />

<bean name="/userRegistration.htm"
class = "com.vaannila.web.UserController"
p:formView = "userForm" p:successView="userSuccess" p:validator-ref="userValidator" />

<bean name="/usersuccesss.htm" class="com.vaannila.web.UserSuccessController">
<property name="commandName" value="usersuccess"/>
<property name="commandClass" value="com.vaannila.domain.UserSuccess"/>
<property name="formView" value="userSuccess"/>
<property name="successView" value="logout"/>
</bean>

</beans>















 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please use the CODE tags when posting code and configuration. I can't read the code without the indentations.

Mark
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also, if you are just learning Spring and Spring MVC, I recommend using material that is up to date.

public class UserController extends SimpleFormController

extending or implementing any Spring Controller class or Interface is not recommended for at least the past 5 years, and are actually now deprecated.

It is much easier and better to use Annotations and current Spring MVC.

Mark
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic