JSP页面无法显示数据库中取出的值,但在测试中可以输出,高手解答 5
JSP界面的代码:<%@pageimport="Models.Flow"%><%@pageimport="Models.FlowImpl"%><%@pageimport=...
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());
}
}
} 展开
<%@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());
}
}
} 展开
2个回答
2014-05-14
展开全部
for(Flow f:flows)
{
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
{
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
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
页面有没有报错
追问
没有
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询