亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

為什么我index.jsp中的session獲取不到利潤集合呢?

public?class?Servlet?extends?HttpServlet?{
????public?void?init()?throws?ServletException{}
????public?void?destroy(){}
????public?void?doGet(HttpServletRequest?request,?HttpServletResponse?response){
????????doPost(request,response);
????}

????public?void?doPost(HttpServletRequest?request,HttpServletResponse?response){
????????Service?service?=?new?Service();
????????try?{
????????????List<Profit>?list?=?service.getProfitList();
????????????request.getSession().setAttribute("ProfitList",list);
????????????response.sendRedirect("index.jsp");
????????}?catch?(Exception?e)?{
????????????e.printStackTrace();
????????}
????}
}
<%@?page?import="java.util.List"?%>
<%@?page?import="com.beans.Profit"?%>
<%@?page?contentType="text/html;charset=UTF-8"?language="java"?%>
<html>
??<head>
????<title>Java原生態生成報表</title>
??</head>
??<body>
??<!--?js格式待做?-->

??<table?class=""?>
????<form?action=""?method="post">
??????<tr?><td?colspan="7">商品利潤表</td></tr>
??????<tr>
????????<th>商品ID</th>
????????<th>商品名</th>
????????<th>成本價</th>
????????<th>銷售價</th>
????????<th>商品總利潤</th>
????????<th>交易次數</th>
????????<th>交易總數</th>
??????</tr>
??<%
????List<Profit>?list?=?null;
????int?temp?=?0;
????int?temp1?=?0;
????int?temp2?=?0;
????int?temp3?=?0;
????int?temp4?=?0;
????int?temp5?=?0;
????if?(session.getAttribute("ProfitList")!=null){
????if?(list==null)?{
??????list?=?(List<Profit>)?session.getAttribute("ProfitList");
????}
????for?(int?i=0;i<list.size();i++){
??????Profit?p?=?list.get(i);
??????if?(p!=null){
??????????temp1?+=?p.getCostPrice();
??????????temp2?+=?p.getSellingPrice();
??????????temp3?+=?p.getPrfit();
??????????temp4?+=?p.getTimes();
??????????temp5?+=?p.getTradingNumber();
??%>
??????<tr>
????????<td><%=temp++%></td>
????????<td><%=p.getGoodsId()%></td>
????????<td><%=p.getGoodsName()%></td>
????????<td><%=p.getCostPrice()%></td>
????????<td><%=p.getSellingPrice()%></td>
????????<td><%=p.getPrfit()%></td>
????????<td><%=p.getTimes()%></td>
????????<td><%=p.getTradingNumber()%></td>
??????</tr>
??????<%
????????}
????????%>
??????<tr>
????????<td?colspan="2">合計</td>
????????<td><%=temp1%></td>
????????<td><%=temp2%></td>
????????<td><%=temp3%></td>
????????<td><%=temp4%></td>
????????<td><%=temp5%></td>
??????</tr>
??????<%
??????????}
????????}
??????%>
????</form>
??</table>
??</body>
</html>


正在回答

1 回答

你的合計在for循環里 ,放外面試試。

0 回復 有任何疑惑可以回復我~
#1

moummm 提問者

非常感謝!
2017-10-07 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

為什么我index.jsp中的session獲取不到利潤集合呢?

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號