第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

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

數(shù)據(jù)無法在表格中顯現(xiàn),數(shù)據(jù)庫測試過了,沒問題

package?service;
//處理數(shù)據(jù)

import?java.sql.Connection;
import?java.sql.PreparedStatement;
import?java.sql.ResultSet;
import?java.sql.SQLException;
import?java.sql.Statement;
import?java.util.ArrayList;
import?java.util.List;

import?org.eclipse.jdt.internal.compiler.batch.Main;



import?Jdbc.JdbcCon;
import?beans.Profit;


public?class?Service?{
	private?static?Connection?con=null;
	private?static?PreparedStatement?st=null,st1=null;
	private?static?ResultSet?rs=null,rs1=null;
	private?static?String?sql,sql1;
	private?static?List?list;//儲存商品信息集合
	private?static?Profit?pf;//利潤
	public?static?List?getReport(){
		
		try?{
			sql="select?goodsList.goods_Id?goodsId,goodsList.goods_Name?goodsName,"+
			"goodsList.cost_Price?costPrice,goodsList.sell_Price?sellPrice?from?goodsList";
			
			con=JdbcCon.getConnection();
			st=con.prepareStatement(sql);
			
			rs=st.executeQuery();
			
			list=new?ArrayList();
			int?temp;
			while(rs.next()){
				pf=new?Profit();
				pf.setGoods_Id(rs.getInt("goodsId"));
				System.out.println(rs.getInt("goodsId"));
				pf.setGoods_Name(rs.getString("goodsName"));
				System.out.println(rs.getString("goodsName"));
				pf.setCostPrice(rs.getInt("costPrice"));
				pf.setSellPrice(rs.getInt("sellPrice"));
				
				
				sql1="select?sum(trading_Number)?sumNumber?from?trading_Information?where?trading_Information.trading_goods_Id=?"+rs.getInt("goodsId");
				st1=con.prepareStatement(sql1);
				rs1=st1.executeQuery();
				while(rs1.next()){
					pf.setTrading_Number(rs1.getInt("sumNumber"));
					System.out.println(pf.getTrading_Number());
					temp=rs.getInt("sellPrice")-rs.getInt("costPrice");
					System.out.println(temp);
					pf.setPf(temp*rs1.getInt("sumNumber"));
					System.out.println(pf.getPf());
				}
				list.add(pf);
			}
			
			return?list;
		}?catch?(SQLException?e)?{
			//?TODO?自動生成的?catch?塊
			e.printStackTrace();
			return?null;
		}finally{
			if(rs!=null){
				try?{
					rs.close();
				}?catch?(SQLException?e)?{
					//?TODO?自動生成的?catch?塊
					e.printStackTrace();
				}
			}
			if?(st!=null)?{
				try?{
					st.close();
				}?catch?(SQLException?e)?{
					//?TODO?自動生成的?catch?塊
					e.printStackTrace();
				}
			}
			if?(rs1!=null)?{
				try?{
					rs1.close();
				}?catch?(SQLException?e)?{
					//?TODO?自動生成的?catch?塊
					e.printStackTrace();
				}
			}
			if?(st1!=null)?{
				try?{
					st1.close();
				}?catch?(SQLException?e)?{
					//?TODO?自動生成的?catch?塊
					e.printStackTrace();
				}
			}
		}
		
		
	}
	
}

package service;


import java.io.IOException;

import java.util.List;


import javax.servlet.ServletException;

import javax.servlet.annotation.WebServlet;

import javax.servlet.http.HttpServlet;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;


//import com.sun.xml.internal.bind.v2.schemagen.xmlschema.List;


/**

?* Servlet implementation class ShowReport

?*/

@WebServlet("/ShowReport")

public class ShowReport extends HttpServlet {

private static final long serialVersionUID = 1L;

? ? ? ?

? ? /**

? ? ?* @see HttpServlet#HttpServlet()

? ? ?*/

? ? public ShowReport() {

? ? ? ? super();

? ? ? ? // TODO Auto-generated constructor stub

? ? }


/**

* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)

*/

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

// TODO Auto-generated method stub

doPost(request, response);

//response.getWriter().append("Served at: ").append(request.getContextPath());

}


/**

* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)

*/

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

// TODO Auto-generated method stub

List list;

list=Service.getReport();

request.getSession().setAttribute("PF",list);//通過session對象將后臺信息傳到前臺

//response.sendRedirect("index2.jsp");

request.getRequestDispatcher("../index2.jsp").forward(request, response);

}


}



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<%@page import="beans.Profit"%>

<%@page import="beans.Goods"%>

<%@page import="java.util.List"%>

<html>

<head>

<%@ page language="java" contentType="text/html; charset=utf-8"

? ? pageEncoding="utf-8"%>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<title>生成報表</title>

<style type="text/css">

.first{

color:#333333;

font-size:13px;

border-width:1px;

border-style:solid;

border-color:#999999;

border-collapse:collapse;

}

.first .second{

border-width:1px;

border-style:solid;

border-color:#a9c6c9;

background-color:#c3dde0;

padding:8px;

}

.three{

border:1px solid #a9c6c9;

padding:8px;

}

</style>

</head>

<body>

<form action="servlet/ShowReport" method="post">

<input type="button" value="生成報表">

<table class="first" border="1px" cellspacing="0">

<tr><th class="second" colspan="6">利潤表</th></tr>

<tr onmousemove="this.style.backgroundColor='#ffff66';"

onmouseout="this.style.backgroundColor='#d4e3e5';">

<th class="three">商品編號</th>

<th class="three">商品名稱</th>

<th class="three">成本價</th>

<th class="three">售價</th>

<th class="three">交易數(shù)量</th>

<th class="three">利潤</th>

</tr>

<%

//List list=(List)request.getSession().getAttribute("report");

int temp1=0,temp2=0;

List list=null;

if(session.getAttribute("PF")!=null){

list=(List)session.getAttribute("PF");

if(list.size()>0){

Profit pf;

for(int i=0;i<list.size();i++){

pf=new Profit();

pf=(Profit)list.get(i);

temp1+=pf.getTrading_Number();

temp2+=pf.getPf();

%>

<tr onmousemove="this.style.backgroundColor='#ffff66';"

onmouseout="this.style.backgroundColor='#d4e3e5';">

<td class="three"><%=pf.getGoods_Id()%></td>

<td class="three"><%=pf.getGoods_Name() %></td>

<td class="three"><%=pf.getCostPrice() %></td>

<td class="three"><%=pf.getSellPrice()%></td>

<td class="three"><%=pf.getTrading_Number()%></td>

<td class="three"><%=pf.getPf()%></td>

</tr>

<%

}

}

}

%>

<tr onmousemove="this.style.backgroundColor='#ffff66';"

onmouseout="this.style.backgroundColor='#d4e3e5';">

<th class="three" colspan="4">合計</th>

<td class="three"><%=temp1%></td>

<td class="three"><%=temp2%></td>

</tr>

</table>

</form>

</body>

</html>



<?xml version="1.0" encoding="UTF-8"?>

<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">

? <display-name>javaweb_5</display-name>

? <welcome-file-list>

? ? <welcome-file>index.html</welcome-file>

? ? <welcome-file>index.htm</welcome-file>

? ? <welcome-file>index.jsp</welcome-file>

? ? <welcome-file>default.html</welcome-file>

? ? <welcome-file>default.htm</welcome-file>

? ? <welcome-file>default.jsp</welcome-file>

? </welcome-file-list>

? <servlet>

? ? <servlet-name>ImageServlet</servlet-name>

? ? <servlet-class>com.javaweb4.ImageServlet</servlet-class>

? </servlet>

? <servlet-mapping>

? ? <servlet-name>ImageServlet</servlet-name>

? ? <url-pattern>/servlet/ImageServlet</url-pattern>

? </servlet-mapping>

? <servlet>

? ? <servlet-name>LoginServlet</servlet-name>

? ? <servlet-class>com.javaweb4.LoginServlet</servlet-class>

? </servlet>

? <servlet>

? ? <servlet-name>ShowReport</servlet-name>

? ? <servlet-class>service.ShowReport</servlet-class>

? </servlet>

? <servlet-mapping>

? ? <servlet-name>ShowReport</servlet-name>

? ? <url-pattern>/servlet/ShowReport</url-pattern>

? </servlet-mapping>

</web-app>


正在回答

1 回答

那是你servlet層的數(shù)據(jù)沒有傳到j(luò)sp頁面,

0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報

0/150
提交
取消

數(shù)據(jù)無法在表格中顯現(xiàn),數(shù)據(jù)庫測試過了,沒問題

我要回答 關(guān)注問題
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號