EL表達式獲取獲取用戶性別信息

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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章