wood burning stoves*
The moose likes Spring and the fly likes Neither BindingResult nor plain target object for bean name 'newAddress' Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Neither BindingResult nor plain target object for bean name Watch "Neither BindingResult nor plain target object for bean name New topic
Author

Neither BindingResult nor plain target object for bean name 'newAddress'

Dharmendra Sharma
Greenhorn

Joined: Apr 08, 2004
Posts: 8
Hi All,

I was working on spring-hibernate based app. Having issue of "Neither BindingResult nor plain target object for bean name 'newAddress' "

The code I have is like below.

Controller code:
------------
@RequestMapping(value="/saveAddress", method=RequestMethod.GET)
public ModelAndView newaddressForm()
{
ModelAndView mav = new ModelAndView("newAddress");
Address address = new Address();
mav.getModelMap().put("newAddress", address);
return mav;
}

@RequestMapping(value="/saveAddress", method=RequestMethod.POST)
public String create(@ModelAttribute("newAddress")Address address, BindingResult result, SessionStatus status)
{
System.out.println("BBBBBBBBBBBBBBB");
validator.validate(address, result);
if (result.hasErrors())
{
return "newAddress";
}
addressDAO.save(address);
status.setComplete();
return "redirect:viewAllAddress.do";
}



Jsp Code:
-----------
<form:form action="saveAddress.do" method="post" commandName="newAddress">


Please someone guide me where I am doing wrong. Help is highly appreciated

Thanks,
Dharmendra Sharma
Bill Gorder
Bartender

Joined: Mar 07, 2010
Posts: 1648
    
    7

Where is the rest of your form? Are you actually binding an Address object to it ? Also are you submitting the form with a typical form submit or are you using Ajax or some other means?

Also I would move to the newer modelAttribute tag although command will still work




On a side note this method:



Could be simplified to this:



Or alternatively



It looks a little confusing since you chose to have your view name and model attribute name be the same. But in both cases its the view name being returned.

[How To Ask Questions][Read before you PM me]
Dharmendra Sharma
Greenhorn

Joined: Apr 08, 2004
Posts: 8
Thanks Bill for your advise. The issue resolved. Actually I was not calling the page as per configuration and was not able to resolve the name. Thank you so much for your suggestion again.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Neither BindingResult nor plain target object for bean name 'newAddress'
 
Similar Threads
@ModelAttribute
Error on View - MultiActionController + Spring:bine
Neither BindingResult nor plain target object for bean name 'command' available as request attribute
spring form submission
Getting error in implementing Spring MVC