• 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

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

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Bartender
Posts: 1682
7
Android Mac OS X IntelliJ IDE Spring Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Dharmendra Sharma
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic