taglib引入struts标签的使用

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
  <s:form action="form" theme="xhtml">
    <s:textfield label="姓名" name="name" labelposition="left"></s:textfield>
    <s:password label="密码" name="psw" showPassword="true"></s:password>
    <s:textarea label="介绍" name="name"></s:textarea>
    <s:checkbox label="是否同意" name="yes_no"></s:checkbox>
    <s:bean var="data" name="tarena.actions.DataBean"></s:bean>
    <s:checkboxlist name="checks" list="#data.boxs" listKey="no" listValue="name"></s:checkboxlist>
    <s:radio name="radios" list="#data.boxs" listKey="no" listValue="name"></s:radio>
    <!-- optgroup使用示例1 -->
    <s:select emptyOption="true" headerKey="0" headerValue="----请选择----" name="radios" list="#data.boxs" listKey="no" listValue="name"></s:select>
 
    <s:select name="sel" list="#data.females"  listKey="no" listValue="name">
        <s:optgroup list="#data.males" listKey="no" listValue="name"></s:optgroup>
    </s:select>
    <!-- optgroup使用示例2 -->
    <s:select name="sel" list="{}" emptyOption="false">
        <s:optgroup label="女性" list="#data.females" listKey="no" listValue="name"></s:optgroup>
        <s:optgroup label="男性" list="#data.males" listKey="no" listValue="name"></s:optgroup>
    </s:select>
    
    <!-- 定义一个map对象,根据map元素创建option选项 -->
    <s:select list='#{"name":"tom","age":20}' listKey="key" listValue="value"></s:select>
    
    <s:submit value="提交"></s:submit>
</s:form>

 

 

<s:actionmessage/>
    <s:form action="login" namespace="/author">
        <s:textfield label="用户名" name="name"></s:textfield><br>
        <s:password label="密码" name="pwd"></s:password><br>
        <s:submit value="登录"></s:submit>
   </s:form>

 

 

 

<s:bean var="data" name="tarena.actions.DataBean"></s:bean>
<ul>
<!-- 集合过滤 
?表示返回满足条件的所有元素 
^表示返回满足条件的第一个元素
$表示返回满足条件的最后一个元素 
#this代表集合中的元素对象-->
<s:iterator value="#data.boxs.{?#this.age>=20}">
    <li>${no }:${name }:${age }</li>
</s:iterator>
</ul>


<hr>通用标签<br>
name:<s:property value="name"/><br>
<!-- 格式化输出date类型属性 -->
date:<s:property value="birth"/>  <s:date name="birth" format="yyyy/MM/dd hh:mm:ss"/>
<!-- 声明age变量,值为20 -->
<s:set var="age" value="20"></s:set>
<s:property value="#age"/><br>
<!-- 将value值压入root栈中,充当栈顶 -->
<s:push value='"aaaaaa"'>
    <s:debug></s:debug>
</s:push>
<hr>
逻辑标签<br>

<s:property value='sex.equals("m")'/>
<s:if test='sex.equals("m")'>男</s:if>
<s:elseif test='sex.equals("f")'>女</s:elseif>
<s:else>人妖</s:else>
<br>
<table>
<tr>
<td>序号</td>
        <td>编号</td>
        <td>姓名</td>
        <td>性别</td>
        <td>年龄</td>
    </tr>
<s:iterator value="persons" var="p" status="stat"><!-- stat为迭代状态对象,类型为IteratorStatus -->
    <tr>
        <td><s:property value="#stat.count"/></td>
        <td><s:property value="#p.no"/></td>
        <td>${p.name }</td>
        <td><s:property value="#p.sex"/></td>
        <td><s:property value="#p.age"/></td>
    </tr>
</s:iterator>
</table>
<hr>
<table>
<tr>
<td>序号</td>
        <td>编号</td>
        <td>姓名</td>
        <td>性别</td>
        <td>年龄</td>
    </tr>
<s:iterator value="persons" status="stat">
    <tr>
        <td>${stat.index+1 }</td>
        <td>${no }</td>
        <td>${name }</td>
        <td><s:property value="sex"/></td>
        <td><s:property value="age"/><br></td>
    </tr>
</s:iterator>
</table>
</body>
</html>

你可能感兴趣的:(html,bean,XHTML,struts,F#)