Textfield Tag (Form Tag) Example
In this section, we are going to describe the textfield tag. The textfield tag is a UI tag that is used to render an HTML input field of type text.
Add the following code snippet into the struts.xml
file.
struts.xml
<action name="textfieldTag"> <result>/pages/uiTags/textfieldTag.jsp</result> </action> |
Create a jsp using the tag <s:textfield >
that renders an HTML input field of type text.
<s:textfield label="Employee Name" name="empname" size="15" maxlength="10" />
tag
displays
an HTML text field with label equal to Employee Name
with length of 15 columns.
textfieldTag.jsp
<%@ taglib prefix="s" uri="/struts-tags" %> <html> <head> <title>Textfield Tag Example</title> </head> <body> <h1><span style="background-color: #FFFFcc">Textfield Tag Example!</span></h1> <s:form> <s:textfield label="Employee Name" name="empname" size="15" maxlength="10" /> </s:form> </body> </html> |
Output of the textfieldTag.jsp: