You may encounter this problem when using spring MVC.
Neither Bindingresult nor plain target object for bean
There are two of messages in this sentence:
(1) Plain target object: This means that there is a modelattribute (for example, a) in the JSP page, and the returned model does not have this a.
This problem is generally easier to find.
(2) not only (1) No, Bindingresult also not. This happens when the parameters of the @valid method are used.
Like what:
... function (@Valid User user_a,bindingresult bindingresult)
{
...
}
When a valid check error occurs, the error is reported because:
If you do not specify the name of user_a in the model, Spring MVC adds an object with the same class name in Bindingresult (the first letter lowercase), this is the user, not the user_a
Solutions are:
Add a model definition before the user user_a: @Valid @ModelAttribute ("user_a") User user_a
This tells the Bindingresult function to name the instance of the error Pojo object user_a instead of the user.
Spring MVC Neither Bindingresult nor plain target object for bean