Spring MVC Neither Bindingresult nor plain target object for bean

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.