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

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

這是我的源碼 為什么運行不了(順便分享一下源碼)

四個實體類就不貼了

//JDBC類下的連接

package?jdbc;

import?java.sql.Connection;
import?java.sql.DriverManager;
import?java.sql.SQLException;

public?class?jdbcConn?{
	
	private?static?String?URL="jdbc:mysql://localhost:3306/report_form";
	private?static?String?user="root";
	private?static?String?password="123456";
	
	public?static?Connection?conn;
	
	public?static?void?main(String[]?args)?throws?SQLException?{
		jdbcConn?jdbc?=?new?jdbcConn();
		System.out.println(jdbc.getConnection().isClosed());
	}
	
	public?static?Connection?getConnection(){
		try?{
			Class.forName("com.mysql.jdbc.Driver");
			conn?=?DriverManager.getConnection(URL,?user,?password);
		}?catch?(ClassNotFoundException?e)?{
			e.printStackTrace();
		}?catch?(SQLException?e)?{
			e.printStackTrace();
		}
		return?conn;
	}
}


//servlet類
package?servlet;

import?java.io.IOException;
import?java.util.List;

import?javax.servlet.ServletException;
import?javax.servlet.http.HttpServlet;
import?javax.servlet.http.HttpServletRequest;
import?javax.servlet.http.HttpServletResponse;

import?service.Service;

/**
?*?Servlet?implementation?class?Report
?*/

public?class?Report?extends?HttpServlet?{
	private?static?final?long?serialVersionUID?=?1L;
???????
????/**
?????*?@see?HttpServlet#HttpServlet()
?????*/
????public?Report()?{
????????super();
????}

	/**
	?*?@see?HttpServlet#doGet(HttpServletRequest?request,?HttpServletResponse?response)
	?*/
	protected?void?doGet(HttpServletRequest?request,?HttpServletResponse?response)?throws?ServletException,?IOException?{
		doPost(request,?response);
	}

	/**
	?*?@see?HttpServlet#doPost(HttpServletRequest?request,?HttpServletResponse?response)
	?*/
	protected?void?doPost(HttpServletRequest?request,?HttpServletResponse?response)?throws?ServletException,?IOException?{
		
		Service?serv?=?new?Service();
		List?list?=?serv.getProfit();
		
		request.getSession().setAttribute("REPORT",?list);
		response.sendRedirect("index.jsp");
	}

}

//service類
package?service;

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

import?beans.Profit;
import?jdbc.jdbcConn;

public?class?Service?{
	
	private?Connection?jdbcconn;?
	private?Statement?st,st2,st3;
	private?ResultSet?rs,rs2,rs3;
	private?String?sql,sql2,sql3;
	private?List?list;
	private?Profit?pf;
	
	public?List?getProfit(){
		list?=?new?ArrayList();
		jdbcconn?=?jdbcConn.getConnection();
		try?{
			st?=?jdbcconn.createStatement();
			st2?=?jdbcconn.createStatement();
			sql="SELECT?g.name?gName,?g.cost_price?gCost,"
					+?"g.selling_price?gSelling,g.id?gId?"
					+?"FROM?goods?g?,trading?t?"
					+?"WHERE?g.id?=t.goods_id?"
					+?"GROUP?BY?g.name?,?g.cost_price?,g.selling_price?,g.id";
			rs?=?st.executeQuery(sql);
			int?temp;
			while(rs.next()){
				pf?=?new?Profit();
				pf.setGoods_name(rs.getString("gName"));
				pf.setCostPrice(rs.getInt("gCost"));
				pf.setSellingPrice(rs.getInt("gSelling"));
				pf.setGoods_id(rs.getInt("gId"));
				
				temp?=?0;
				temp?=?pf.getSellingPrice()?-?pf.getCostPrice();
				
				//得到單品交易總量
				sql2="SELECT?SUM(t.number)?sumNum?FROM?trading?t?WHERE?t.goods_id?=?"?
						+pf.getGoods_id();
				rs2?=?st2.executeQuery(sql2);
				while?(rs2.next()){
					pf.setTradingNum(rs2.getInt("sumNum"));
				}
				
				//利潤匯總
				pf.setProfit(temp*pf.getTradingNum());
				
				//得到time訂單數(shù)量
				sql3="SELECT?count(t.number)?countNum?FROM?trading?t?WHERE?t.goods_id?=?"?
						+pf.getGoods_id();
				rs3?=?st3.executeQuery(sql2);
				while?(rs3.next()){
					pf.setTime(rs3.getInt("countNum"));
				}
				
				//加入到List中
				list.add(pf);
				
			}
			
		}?catch?(SQLException?e)?{
			e.printStackTrace();
		}
		
		return?list;
	}
}
//index.jsp部分
<%@?page?language="java"?import="java.util.*?,beans.*"?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">
<html>
??<head>
????<base?href="<%=basePath%>">
????
????<title>原生態(tài)JAVA生成報表</title>
	<meta?http-equiv="pragma"?content="no-cache">
	<meta?http-equiv="cache-control"?content="no-cache">
	<meta?http-equiv="expires"?content="0">????
	<meta?http-equiv="keywords"?content="keyword1,keyword2,keyword3">
	<meta?http-equiv="description"?content="This?is?my?page">
	<!--
	<link?rel="stylesheet"?type="text/css"?href="styles.css">
	-->
	
	<style?type="text/css">
		table.hovertable?{
			font-family:?verdana,?arial,?sans-serif;
			font-size:?13px;
			color:?#333333;
			border-width:?1px;
			border-color:?#999999;
			border-collapse:?collapse;
		}
		
		table.hovertable?th?{
			background-color:?#c3dde0;
			border-width:?1px;
			padding:?8px;
			border-style:?solid;
			border-color:?#a9c6c9;
		}
		
		table.hovertable?tr?{
			background-color:?#d4e3e5;
		}
		
		table.hovertable?td?{
			border-width:?1px;
			padding:?8px;
			border-style:?solid;
			border-color:?#a9c6c9;
		}
	</style>
	
??</head>
??
??<body>
?????<br>
????<from?action="Report"?method="post">
????	<input?type="submit"?value="生成報表"/><br>
????</from>
????<table?class="hovertable">
????	<!--?生成表頭?-->
????	<tr>
????		<th?colspan="5"?align="center">利潤表</th>
????	</tr>
????	<tr>
????		<th>序號</th>
????		<th>商品名稱</th>
????		<th>賣出交易</th>
????		<th>交易筆數(shù)</th>
????		<th>盈利額</th>
????	</tr>
????	<%?
????	List?list?=?null;
????	if(session.getAttribute("REPORT")?!=?null){
????		//得到數(shù)據(jù)表
????		list?=?(List)?session.getAttribute("REPORT");
????		
????		if(list.size()>0){
????			int?temp1?=0;
????			int?temp2?=0;
????			int?temp3?=0;
????			int?temp4?=0;
????			Profit?pf;
????			for(int?i?=0;i<list.size();i++){
????				pf?=?new?Profit();
????				pf?=?(Profit)?list.get(i);
????				temp2+=pf.getTradingNum();
????				temp3+=pf.getTime();
????				temp4+=pf.getProfit();
????				
????	%>
??				<tr?onmouseover="this.style.backgroundColor='#ffff66';"
						onmouseout="this.style.backgroundColor='#d4e3e5'">
??					<td><%=temp1++?%></td>
??					<td><%=pf.getGoods_name()?%></td>
??					<td><%=pf.getTradingNum()?%></td>
??					<td><%=pf.getTime()?%></td>
??					<td><%=pf.getProfit()?%></td>
??				</tr>
????	<%
????			}%>
????			
??				<tr?onmouseover="this.style.backgroundColor='#ffff66';"
						onmouseout="this.style.backgroundColor='#d4e3e5'">
??					<td?colspan="2">合計</td>
??					<td><%=temp2?%></td>
??					<td><%=temp3?%></td>
??					<td><%=temp4?%></td>
??				</tr>
????			
????			
????		<%}
????	}
????	%>
????</table>
????
??</body>
</html>

為什么出錯完全沒反應(yīng) index.jsp頁面只出現(xiàn)表頭 不能轉(zhuǎn)跳

正在回答

1 回答

我之前也出現(xiàn)這種錯誤,我的是因為Servlet是自動生成的,所以沒有改web.xml,用的它生成的,后來檢查之后發(fā)現(xiàn)路徑不對,將web.xm中url路徑修改成這樣就ok了

<servlet-mapping>

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

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

? </servlet-mapping>

你可以參考一下是否是這個原因,希望對你有幫助。

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

舉報

0/150
提交
取消
使用JSP+Servlet技術(shù)生成報表
  • 參與學(xué)習(xí)       69834    人
  • 解答問題       98    個

Java Web案例課程,教你如何使用JSP+Servlet技術(shù)生成報表

進入課程

這是我的源碼 為什么運行不了(順便分享一下源碼)

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

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

幫助反饋 APP下載

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

公眾號

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