Friday, May 3, 2013

Resolving Neither BindingResult nor plain target object issue

The common error stack we observe when we are working with spring tag library is 'Neither BindingResult nor plain target object for bean name available as request attribute'. 

The error message itself explaining that we have not mentioned the corresponding command object details (command name, command class).

When we face this problem:

When we are using forms in our application, in general we will use tag library provided by spring

i.e, 

As part of the  spring tag library we have tag's to use different html components as part of our application (like form, textfiled,checkbox .. etc).

Here is the sample code ..


Here we have not mentioned the commandName attribute as part of form tag, which means we have not provided the details of command object.

one more case we may observe .,


In the spring-servlet.xml we have configured our class SaveDataController with all required properties except commandName. This is the other case where we used to get the same error.

How to Resolve this :

The solution to the above mentioned problem is so simple. We need to provide command object details in order to avoid this error.

Here is the solution



We have provided commandName attribute for the  and



here we have provided the commandName property for the SaveDataController class.


That's it. Remember , We need to cofigure everything as part of our xml files and in case of forms we need to provide commandName and commandClass

Special Case:

For e.g i have a form without any fields and only have button (ofcourse, in general we may not face this situation , form without input fileds)


Here we have used only button within the form. In this case we don't need any command class.

As command class is used to get the data from the form and store that collected data from the form into command object and here we don't have any input fileds to collect the data entered by user. That's why we no need to provide command object details.


5 comments:

  1. ⭐ Data Analyst Course
    A practical data analyst course helps you master analysis from basics to advanced.
    You learn Excel, SQL, Python, and visualization tools with real datasets.
    Hands-on projects improve your practical understanding.
    Live sessions make learning interactive and clear.
    Expert trainers guide you step by step.
    This course prepares you for real data analyst roles.

    ReplyDelete
  2. Enroll in salesforce developer classesto master Apex, Visualforce, and Lightning components, accelerating your CRM and cloud development skills. These Salesforce developer classes offer hands-on projects and expert guidance to boost your career in Salesforce development.

    ReplyDelete
  3. Enhance your data skills with power bi training online classes designed for beginners and professionals alike. Learn to create interactive dashboards and insightful reports from anywhere, at your own pace.

    ReplyDelete
  4. Wonderful read! Learn boomi course
    to design, deploy, and manage integrations for modern cloud and on-premise apps.

    ReplyDelete
  5. Advanced Python course focuses on deep programming techniques. It explains advanced libraries and frameworks. This advanced python course enhances expertise. It includes real-time projects. Students gain technical mastery. It is career focused.

    ReplyDelete