Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use spring form tags or not?

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!

like image 883
Bobo Avatar asked Dec 01 '10 15:12

Bobo


People also ask

What are Spring form tags?

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.

Which tag in Spring MVC will be used to?

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.

Why do we use Spring forms?

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.

What is use of @ModelAttribute?

@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.


1 Answers

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.

like image 105
skaffman Avatar answered Oct 02 '22 14:10

skaffman