You are here
Home >

java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name ‘command’ available as request attribute : Spring Boot | neither bindingresult nor plain target object for bean name ‘command’ available as request attribute | neither bindingresult nor plain target object for bean name | java.lang.illegalstateexception: neither bindingresult nor plain target object for bean name | neither bindingresult nor plain target object for bean name available as request attribute | neither bindingresult nor plain target | java.lang.illegalstateexception: neither bindingresult nor plain target object for bean name ‘user’ available as request attribute | neither bindingresult nor plain target object for bean name ” available as request attribute |neither bindingresult nor plain target object for bean | neither bindingresult nor plain target object for bean name ‘form’ available as request attribute | caused by: java.lang.illegalstateexception: neither bindingresult nor plain target object for bean name | neither bindingresult nor plain target object for bean name ‘login’ available as request attribute neither bindingresult nor plain target object for bean name

Problem :

When I use Spring form tags I get below errors in console

java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name ‘command’ available as request attribute : Spring Boot

java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'command' available as request attribute : Spring Boot

Solution :

Make sure two things are available in your code as highlighted in below screenshots.

Step #1:

In UI page, check if you have added modelAttribute property. Its value is by default the name of your entity class starting with a lower case letter. eg. If the entity class name is ‘Invoice’, the value of your modelAttribute will be ‘invoice’.

Step #2:

In controller’s request handler method, you have object creation logic in place or not. In my case its ‘new Invoice()‘.

These steps are mandatory if you are using Spring form tags even in case of thymeleaf also. If you are using html/jsp form tags these steps are not required.

modelAttribute

We must have to create the object of entity class as shown in the below screenshot. We have done it by using new() operator.

modelAttribute2

If you verify it at both the places and correct it, I am sure your exception will get resolved.

This is the most common exception that almost every beginner faces at the time of development. On the other hand, this solution is perfect for this exception. One point to notice here that this exception doesn’t occur when we use HTML or JSP technology at front end. In contrast, this occurs when we use Spring forms or Thymeleaf etc.

 

java.lang.illegalstateexception: neither bindingresult nor plain target object for bean name ‘command’ available as request attribute| neither bindingresult nor plain target object for bean name ‘command’ available as request attribute| neither bindingresult nor plain target object for bean name available as request attribute| java.lang.illegalstateexception: neither bindingresult nor plain target object for bean name| neither bindingresult nor plain target object for bean name ‘user’ available as request attribute| neither bindingresult nor plain target| neither bindingresult nor plain target object for bean name ” available as request attribute| java.lang.illegalstateexception: neither bindingresult nor plain target object for bean name available as request attribute| java.lang.illegalstateexception: neither bindingresult nor plain target object for bean name ‘user’ available as request attribute| caused by: java.lang.illegalstateexception: neither bindingresult nor plain target object for bean name| neither bindingresult nor plain target object for bean name ‘login’ available as request attribute

| neither bindingresult nor plain target object| neither bindingresult nor plain target object for bean| neither bindingresult nor plain target object for bean name ‘form’ available as request attribute| neither bindingresult nor plain target object for bean name ‘customer’ available as request attribute| neither bindingresult nor plain target object for bean name ‘command’ available as request attribute java.lang.illegalstateexception: neither bindingresult nor plain target object for bean name ‘command’ available as request attribute| neither bindingresult nor plain target object for bean name available as request attribute thymeleaf| neither bindingresult nor plain target object for bean name ‘name’ available as request attribute| java.lang.illegalstateexception: neither bindingresult nor plain target object for bean name ” available as request attribute| bindingresult nor plain target object for bean name| neither bindingresult nor plain target object for bean name ‘command’|

neither bindingresult nor plain target object for bean name ’employee’ available as request attribute

Leave a Reply


Top