随笔-200  评论-148  文章-15  trackbacks-0
<%@ 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>显示用户信息</title>
</head>
<body>
<s:iterator id="it" value="list" status="st">
 <s:property value="username" />---<s:property value="password" />--<s:property
  value="gender" />-----  
    <s:if test="gender.toString()==@cn.ssh.domain.Gender@MAN.toString()">男</s:if>
 <s:else>女</s:else>
 --
 <s:if test="gender.toString()=='MAN'.toString()">男</s:if>
 <s:else>女</s:else>
 <br>
list是action中的
</s:iterator>
<s:debug></s:debug>
</body>
</html>

也可以采用如下方式

public enum Gender {
 MAN {
  public String getSex() {
   return "男";
  }
 },
 WOMEN{
  public String getSex() {
   return "女";
  }
 };
}

<%@ 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>显示用户信息</title>
</head>
<body>
<s:iterator value="list">
 <s:property value="username" />---<s:property value="password" />--<s:property value="gender.sex" /> 
   
 <br>
</s:iterator>
<s:debug></s:debug>
</body>
</html>

struts2标签真是强大
posted on 2010-11-04 15:19 无声 阅读(3637) 评论(0)  编辑  收藏 所属分类: 职场生活

只有注册用户登录后才能发表评论。


网站导航: