<%@ page language="java" import="java.util.*" contentType="text/html; charset=UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body>
<s:set name="age" value="50" />
<s:if test="#age > 60">
老年人
</s:if>
<s:elseif test="#age > 35">
中年人
</s:elseif>
<s:elseif test="#age > 15">
青年人
</s:elseif>
<s:else>
少年
</s:else>
<hr />
<s:iterator id="name" value="{'張三', '李四', '王五'}">
<s:property value="name" />
</s:iterator>
<s:iterator id="name" value="#{'張三':'haohaoxuexi', '李四':'tiantianxiangshang', '王五':'hahaha'}" status="status">
<s:if test="#status.odd">
<div style="background-color: red;">
</s:if>
<s:else>
<div style="background-color: blue;">
</s:else>
<s:property value="key" />
<s:property value="value" />
</div>
</s:iterator>
</body>
</html>
效果如下:
[img]http://dl.iteye.com/upload/attachment/486895/56e874de-a52d-3918-9353-743184006ea5.jpg[/img]