I am beginning with struts2 programming and I wondered how I could do the following thing. I have this struts code in a form :
<s:textfield name="aName"/>
And I had this html code before using struts2 :
<input id="aLogin" type="text" class="form-control" name="username" value="" placeholder="something" required autofocus>
How could I "merge" these two lines to do the same html code but using my struts2 code ?
In Struts tags,
class
ansstyle
becomescssClass
andcssStyle
; in old versions of Struts,required
was an attribute indicating when to put the*
mark, now changed torequiredLabel
to avoid overriding the HTML5 required attribute. Other HTML5 attributes likeplaceholder
andautofocus
can be set because Textfield tag Allows Dynamic Attributes.Then in your case:
For other info, refer to the official
<s:textfield/>
documentationname should be same as that of bean variable,therefore,
this will work, only if you have setUsername method in your action class.