Like the errors tag, the messages tag looks for the ActionErrors object referenced by the scoped variable whose name is the same as the value of the ERROR_KEY field of the org.apache.struts.Globals class. However, it does not display the messages inside the ActionErrors object. Instead, it iterates the collection and, for each iteration, creates a scoped variable referencing the iterated ActionError object. To actually display the error messages, you can use the Bean Tag Library’s write tag nested inside the messages tag. Compared to the errors tag, the messages tag gives you control over the formatting of the error messages without having to rely on the errors.header, errors.footer, errors.prefix, and errors.suffix keys in your properties file.
As an example, the following messages tag displays the validation error messages of the current action form.
<html:messages id="item"> <li><bean:write name="item"/></li> </html:messages>
Notice that the id attribute of the messages tag specifies the scoped variable that references the ActionError object for each iteration.