Home > FAQs > Why do the form tags put table tags around controls |

Apache Struts 2 Documentation
Why do the form tags put table tags around controls
Edit Page Browse Space Add Page Add News

The form tags are designed to generate standard markup around control tags. What markup the tags generate is determined by a "theme". A theme is a set of templates and stylesheets that work together to generate the Struts Tags.

The `simple` theme does not inject any default markup, and lets us add whatever special markup we want around the tags. To use the `simple` theme throughout an application, we can add this line to the struts.properties file, and place the file under `WEB-INF/classes`, next to the `struts.xml`.

The theme can also be specified as part of the form tag, if we just want to handcode a particular form.

The general idea is that we can create a form just by specifying the fields, and let the theme generate the HTML markup for us. (Like using an advanced stylesheet.) The default theme has handy features such as automatically displaying validation errors above each field, with any extra work on our part.

For example, a form like this

using the default XHTML team, renders like this

Generated HTML fragment

Note that the Struts 2 tags include new attributes, like "label". The XHTML (and AJAX) themes will automatically inject a label tag into the form.

Of course, as mentioned, we can always use the simple theme and inject all themarkup by hand, just like Struts 1.

The themes and individual tags can also be extended, if need be, to meet any specific needs of an application.

For more, see Themes and Templates.