Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When should I use html's <form> and when spring's <form:form> in Spring MVC web app?

I am wondering is it good practice to write all forms in spring tags or can I mix spring form tags with html form tags?

like image 274
newb Avatar asked Feb 22 '11 13:02

newb


2 Answers

Use Spring forms when you need functionality provided by them:

  • binding to objects
  • configurable field formatting
  • redisplay of values on errors
  • binding of error messages

For simple forms (such as a simple search box on each page) you usually don't need these features - therefore you can use simple HTML forms for them.

like image 73
axtavt Avatar answered Nov 15 '22 18:11

axtavt


Springs form:form tag is supposed to be used with whenever you have a formbacking object you wish to bind to the form (a model object delivered to your view).

There are no additional benefits of using the tag in a regular form with no backing object.

like image 36
Johan Sjöberg Avatar answered Nov 15 '22 18:11

Johan Sjöberg