日期:2014-05-17  浏览次数:20654 次

无法用c:forEach
在我代码里可以for循环输出信息,但我因其它要用c:foreach循环输出信息,但始终无法输出成功,标签配置我已经用另外一个jsp测试正确,到底该怎么做啊?
<%@ page language="java" import="java.util.List" pageEncoding="gb2312"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib  prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@page import="Train.ticket"%>
<html>
  <head> 
    <title>查询结果</title>
  </head> 
  <body>
    <%
    ticket Ticket=new ticket();
     List<ticket> ticketList=Ticket.select_tiket_train_from_to(request.getParameter("train_from"),request.getParameter("train_to"),request.getParameter("train_time"));
 // for(int i=0;i<ticketList.size();i++){
//      ticket tickets=(ticket)ticketList.get(i);
//      out.println(tickets.tikets_no);
//      }
 
  pageContext.setAttribute("a",ticketList);
     %>
     <table width="800" border="1">
      <tr>
      <td>火车票编号</td>
      <td>火车车次</td>
      <td>出发地</td>
      <td>目的地</td>
      <td>发车时间</td>
      <td>到达时间</td>
      <td>座位类型</td>
      <td>票价</td>
      <td>票数</td>
      <td>剩余票数</td>
      </tr>
       <c:forEach var="Tickets" items="${pageScope.a}">
    <tr>
     <td>${Tickets.tikets_no}</td>
      <td>${Tickets.train_no}</td>
      <td>${Tickets.train_from}</td>
      <td>${Tickets.train_to}</td>
      <td>${Tickets.train_time}</td>
      <td>${Tickets.train_to_time}</td>
      <td>${Tickets.seat_typle}</td>
      <td>${Tickets.train_price}</td>
      <td>${Tickets.tikets_all_num}</td>
      <td>${Tickets.tikets_lift_num}</td>  
    </tr>  
     </c:forEach> 
     </table>
  </body>
</html>
jsp? jstl c:foreach list

------解决方案--------------------
错误那里已经提示的很清楚了,就是说在你的Train.ticket里面