EL表达式获取获取用户性别信息

来源:互联网 发布:淘宝小号哪里买的安全 编辑:程序博客网 时间:2024/05/21 11:34

1、Action后台中session对象中保存的数据

public String find() {list = empdao.finduser();ServletActionContext.getRequest().getSession().setAttribute("userlist",list);return "alluserPage";}

2、使用el表达式将action中保存在session对象中的数据获取显示在页面

1)导入taglib指念

<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
2)使用foreach将session中的对象循环取出,在进行判断性别

<c:forEach items="${sessionScope.userlist}" var="user">            <tr>               <td>${user.TId}</td>               <td>${user.PId}</td>               <td>${user.TName}</td>               <td>                 //第一种方法                 <c:if test="${user.TSex eq 1}">男</c:if>                 <c:if test="${user.TSex eq 0}">女</c:if>                 //第二种方法                 <c:if test="${user.TSex==1}">男</c:if>                 <c:if test="${user.TSex==0}">女</c:if>               </td>               <td>${user.TUsername}</td>               <td>${user.TPassword}</td>               <td>${user.TRegtime}</td>            </tr></c:forEach>
3、运行结果


4、El关系运算符


参考网站:http://www.cnblogs.com/Fskjb/archive/2009/07/05/1517192.html

0 0
原创粉丝点击