JSP界面的代码:
<%@page import="Models.Flow"%>
<%@page import="Models.FlowImpl"%>
<%@page import="java.util.*"%>
<%@page import="java.util.ArrayList"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>学生信息列表</title>
</head>
<body>
<table bgcolor=lightgrey>
<tr><td>流水单号</td><td>交易额</td><td>优惠交易额</td><td>日期</td><td>删除</td><td>修改</td></tr>
<%FlowImpl fl = new FlowImpl(); ;
ArrayList<Flow> flows = fl.getAllFlow();
for(Flow f:flows)
{%>
<tr bgcolor=cyan><td><a href="/Xs/servlet/ToDditFlow?id=<%=f.getId() %>"><%=f.getId() %></a></td>
<td><%=f.getPrice() %></td>
<td><%=f.getFprice() %></td>
<td><%=f.getDate() %></td>
<td> <a href="/Xs/servlet/DoDeleteFlow?id=<%=f.getId()%>"> 删除</a> </td>
<td><a href="/Xs/servlet/ToDditFlow?id=<%=f.getId() %>">修改</a></td>
</tr>
<%
}
%>
<tr><td><a href="/Xs/addFlow.jsp">添加流水单</a></td></tr>
</table>
<form method="post" action="/Xs/servlet/DoFindFlowById">
<table>
<tr> <td><input type="text"name="idsearch"></td>
<td> <input type="submit" name="searchbyid"value="流水单号查找">
<input type="submit"name="searchwithid"value="模糊查询">
</td>
</tr>
</table>
</form>
<form method="post"action="/Xs/servlet/DoFindFlowWithCombo">
<table>
<tr><td><input type="text"name="content1"></td><td><input type="text"name="content2"></td>
<td><input type="submit"value="组合查询"></td></tr>
</table>
</form>
</body>
</html>
测试的代码:
package Models;
import java.util.ArrayList;
public class Test {
public static void main(String[] args)
{
FlowImpl fl = new FlowImpl();
ArrayList<Flow> flows = fl.getAllFlow();
for(Flow f:flows)
{
System.out.println(f.getId());
System.out.println(f.getPrice());
System.out.println(f.getFprice());
System.out.println(f.getDate());
}
}
}
{
out.println("<tr bgcolor=cyan><td><a href=\"/Xs/servlet/ToDditFlow?id="+f.getId() +"\">"+f.getId() +"</a></td><td>"+f.getPrice()+ "</td><td>"+f.getFprice() +</td><td>"+f.getDate()+" </td><td> <a href=\"/Xs/servlet/DoDeleteFlow?id="+f.getId()+"\"> 删除</a> </td><td><a href=\"/Xs/servlet/ToDditFlow?id="+f.getId() +"\">修改</a></td></tr>)
}
试试这么写FOR
没有