Java – how to run formbackingobject and referencedata objects in spring web MVC cycle?
I am new to the spring framework and try to understand the functions of formbackingobjects and compare them with the referencedata method. When I try to associate them with the HTTP request loop of spring MVC, these objects will confuse me
As an example, I really appreciate someone who can explain these two objects
Q: what is the difference between a formbacking object and a reference data object?
Solution
When loading a web page, you will need to pass data so that it can be rendered
Some of the data will be purely informational and read-only; The page needs to render data, but this is not part of the current transaction Example: fill in the country list in the drop-down list and the list of possible products that users can buy
Other data will be used for reading and writing: the contents of the form must be filled with the current data, but can also be updated by the user This set of data will be bound to the form; The data sent to the page will be rendered, and the data sent from the page (by the user) will result in an update Example: user name and address; Current order
All this data will usually be stored in one or more objects that the page needs to access
Objects containing information data should be placed in the mapping provided by the referencedata () method There can be many such objects, as you wish
To bind to form data, read / write data must be contained in a single object This object should be returned by the formbackingobject () method
I'll add that in a newer version of spring, annotations are used instead of these "built-in" methods