textfield、textarea、file、checkbox、radio标签
这些标签是最基本的表单标签,会生成HTML里的<input>标签。同form标签一样,这些标签也会根据当前主题生成布局代码,如<TR>,<TD>等,例如:
1 <html> 2 <head> 3 <title>My JSP 'index.jsp' starting page</title> 4 <meta http-equiv="pragma" content="no-cache"> 5 <meta http-equiv="cache-control" content="no-cache"> 6 <meta http-equiv="expires" content="0"> 7 <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> 8 <meta http-equiv="description" content="This is my page"> 9 <!-- 10 <link rel="stylesheet" type="text/css" href="styles.css"> 11 --> 12 13 <struts:head theme="ajax" /> 14 15 <style type="text/css"> 16 body,td { 17 font-size: 12px; 18 } 19 </style> 20 </head> 21 22 <body> 23 24 <struts:form action="login"> 25 <struts:textfield name="textfield" label="文本框" required="true" tooltip="这是一个文本框" /> 26 <struts:password name="password" label="密码域" tooltip="这是密码域" /> 27 <struts:textarea name="textarea" label="文本域" tooltip="这是文本域" /> 28 <struts:file name="file" label="文件域" tooltip="这是文件域" /> 29 <struts:radio list="#{'male':'男', 'female':'女'}" name="sex" label="单选框" tooltip="这是单选框" /> 30 <struts:checkbox name="hobby" label="是否精通 Struts 2" value="true" /> 31 <struts:submit value=" 提 交 " method="logout" align="center" /> 32 </struts:form> 33 34 35 </body> 36 </html>
radio标签的list属性必须是Map类型,key为实际值,value为显示值。如果为List类型,会抛出异常。