`

struts2标签的迭代用法(<s:interator>)的简单用法

 
阅读更多
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!-- 导入struts2标签库 -->
<%@taglib prefix="s" uri="/struts-tags"%>
<!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>
<body>
	<h1>${sessionScope.username}登录成功</h1>
	<label>作者李刚的图书</label>
	<!--迭代输出ValueStack值栈中的books对象,其中status是迭代的符号-->
	<table>
	<s:iterator value="#session.books" status="indexValue" var="book">
		<!-- 判断书号是否为奇数 -->
		<s:if test="#indexValue.odd == true">
			<tr style="background-color:red">
		</s:if>
		<s:else>
			<tr>
		</s:else>
			<td>
				<!-- 输出索引值 -->
				<s:property value="#indexValue.index"/>
				<!-- 依次输出书名 -->
				<s:property value="#book"/>
			</td>
		</tr>
	</s:iterator>
	</table>
</body>
</html>

最终输出结果:

struts2标签的迭代用法(&lt;s:interator&gt;)的简单用法0

文章来源:http://www.itnose.net/detail/6251909.html
更多文章:http://www.itnose.net
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics