Neither BindingResult nor plain target object for bean name 'user' available as request attribute
posted 14 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
I got the Neither BindingResult nor plain target object for bean name 'user' available as request attribute exception when ever there is a form:input path tag in my jsp
Can you please tell me the solution for this
Can you please tell me the solution for this
posted 14 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
provide some code snippet...
Aruna Lukka
Greenhorn
Posts: 5
posted 14 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Controller
public class UserDtls extends SimpleFormController {
protected ModelAndView processFormSubmission(HttpServletRequest request,
HttpServletResponse response, Object command, BindException errors)
throws Exception {
User user=(User)command;
System.out.println("User name is "+user.getUserName());
System.out.println("User location is "+user.getLocation());
return new ModelAndView("First","user",user);
}
}
Mapping in Dispatcher Servlet
<bean id="userDtls" class="com.training.controller.UserDtls">
<property name="commandName">
<value>user</value>
</property>
<property name="commandClass">
<value>com.training.beans.User</value>
</property>
<property name="formView">
<value>welcome</value>
</property>
</bean>
Code in the jsp
<form:form name="user" commandName="user" action="user.htm" method="post">
</form:form>
Thank for your reply
public class UserDtls extends SimpleFormController {
protected ModelAndView processFormSubmission(HttpServletRequest request,
HttpServletResponse response, Object command, BindException errors)
throws Exception {
User user=(User)command;
System.out.println("User name is "+user.getUserName());
System.out.println("User location is "+user.getLocation());
return new ModelAndView("First","user",user);
}
}
Mapping in Dispatcher Servlet
<bean id="userDtls" class="com.training.controller.UserDtls">
<property name="commandName">
<value>user</value>
</property>
<property name="commandClass">
<value>com.training.beans.User</value>
</property>
<property name="formView">
<value>welcome</value>
</property>
</bean>
Code in the jsp
<form:form name="user" commandName="user" action="user.htm" method="post">
| Welcome To Spring Training | Name<form:input path="userName"/> | <input type="submit" value="submit"> |
</form:form>
Thank for your reply
posted 14 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Try to take out "First" local argument from the return ModelAndView, if it not fix the problem then you need to make sure everything is configured correctly.
Try Annotation form controller instead, it's straight forward and no need for XML configuration.
Hope it help...
Try Annotation form controller instead, it's straight forward and no need for XML configuration.
Hope it help...
OCPJP6-05-11
"Your life is in your hands, to make of it what you choose."
Aruna Lukka
Greenhorn
Posts: 5
posted 14 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
I tried the above constructor code but it is not working. Can I solve my problem with out using annotation. Can you please tell me the good tutorial for learning springs
posted 14 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
| I think she's lovely. It's this tiny ad that called her crazy: The new gardening playing cards kickstarter is now live! https://www.kickstarter.com/projects/paulwheaton/garden-cards |










