I am working on a new web project based on Spring MVC 3. Now trying to decide to use spring form tags or not. Personally I don't like to use any tags other than HTML and JSP. It takes time to learn them and it is so hard to understand how they are rendered and the error msgs when they occur. So are there any outstanding advantages to use them? Thank you!
The Spring MVC form tags are the configurable and reusable building blocks for a web page. These tags provide JSP, an easy way to develop, read and maintain. The Spring MVC form tags can be seen as data binding-aware tags that can automatically set data to Java object/bean and also retrieve from it.
Spring Framework provides spring's form tag library for JSP views in Spring's Web MVC framework. In Spring Framework, we use Java Server Pages(JSP) as a view component to interact with the user. From version 2.0, Spring Framework provides a comprehensive set of data binding-aware tags.
View: Spring MVC form tags are used to render the equivalent HTML form fields, and most importantly, bind the object in the model with the form. Controller: alongside with handling requests, the controller binds the model object with the view and vice-versa, and delegates processing to dedicated business/service class.
@ModelAttribute is an annotation that binds a method parameter or method return value to a named model attribute, and then exposes it to a web view. In this tutorial, we'll demonstrate the usability and functionality of this annotation through a common concept, a form submitted from a company's employee.
The Spring MVC form tags are very basic indeed, but they're better than nothing. If you're trying to render HTML forms, with submissions, error messages, and resubmissions, they take a lot of the annoyance away (especially for <select>
fields, which are a huge pain to handle otherwise).
For anything more complex, they're pretty useless, but for forms, I see no reason to not use them.
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