Could you please explain about command object in spring frame work with an example?
Form Backing Object/Command Object This is a POJO that is used to collect all information on a form. It contains data only. It is also called a Command Object in some Spring tutorials. For example, an add a new car form page will have a Car form backing object with attribute data such as Year, Make and Model.
A command data bean relies on a command to retrieve its data and is a more lightweight data bean. The command retrieves all attributes for the data bean at once, regardless of whether the JSP page requires them.
The Spring Boot CLI is a command line tool that you can use if you want to quickly develop a Spring application. It lets you run Groovy scripts, which means that you have a familiar Java-like syntax without so much boilerplate code. You can also bootstrap a new project or write your own command for it.
DispatcherServlet is the front controller in Spring Web MVC. Incoming requests for the HTML file are forwarded to the DispatcherServlet.
from Spring Documentation:
Command Object
- a JavaBean which will be populated with the data from your formsThink of Command Object
as a POJO/JavaBean/etc.. that backs the form in your presentation layer.
Once the form is submitted, all the individual attributes are mapped/bound to this object. On the way up to presentation, Command Object
properties may be used to pre/populate the form.
check an example here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With