<%@ page language="java" import="java.util.*" pageEncoding="utf-8"
isELIgnored="true"%><%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt"%>
<%@taglib uri= "http://java.sun.com/jsp/jstl/core" prefix= "c" %>
<%@taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>房间信息</title></head><body>
房间信息
<hr> <a href="Room!allRoom.action">所有房间信息</a>
<a href="index.jsp">index</a>
<table border="1">
<tr>
<th>房间ID</th>
<th>房间名</th>
<th>房间信息</th>
<th>房间号码</th>
<th>房间价格</th>
<th>房间状态</th>
<th>预定</th>
</tr>
<s:iterator value="#session.allRoom" status="s" id="room">
<tr> <td><s:property value="roomId" /></td>
<td><s:property value="roomName" /></td>
<td><s:property value="roomInfo" /></td>
<td><s:property value="bedsNumber" /></td> <td><s:property value="roomPrice" /></td>
<td><s:property value="roomState" /></td>
<td><s:if test="${sessionScope.allRoom.roomState==1}">已预订</s:if><s:if test=""></s:if>
</td> <td><a href="addOrder.jsp">预定</a></td>
</s:iterator>
</tr>
</table>
</body>
</html>
------------------------------------
<td><s:if test="${sessionScope.allRoom.roomState==1}">已预订</s:if> 但是这个不起作用,怎么办?
-----------------------------------------------
allRoom 是一个list 集合
-------------IteratorJavauristruts

解决方案 »

  1.   

    <s:if test="${sessionScope.allRoom.roomState==1}">已预订</s:if>
    改成
    <s:if test="#room.roomState==1">已预订</s:if>
    试试看
    还有,你的
    <td><s:property value="roomId" /></td>
    前面都没有加'#'号和别名
    <td><s:property value="#room.roomId" /></td>
      

  2.   

    如何你的集合泛型 
    iterator迭代后直接
    <s:if test="roomState==1">已预订</s:if>
    就可以了 
      

  3.   

    谢谢1楼和2楼的大哥 啊!!!!~~~~(>_<)~~~~