@murph
2017-05-13T11:36:42.000000Z
字数 6973
阅读 518
JSP+servlet
简介:报表就是用表格、图表等格式来动态显示数据。本课程是Java Web的案例课程,主要关注于用表格形式来显示数据。主要内容包括报表的基础知识,报表实现原理和核心技术,以及如何使用JSP+Servlet技术来生成报表。
课程须知
学习本课程需要具备JSP和Servlet的基础知识。需要注意的是本课程中使用的是Oracle数据库,但使用MySql数据库也是可以的。
你能学到什么?
1、使用JSP+Sevlet实现报表
2、掌握如何使用MVC模型进行程序开发
什么是报表?
报表生成的关键要素?
学习目标
- Ⅰ 后台数据抽取
- Ⅱ 数据项逻辑运算
- Ⅲ 前台表格展示
报表在项目中的地位?
统计信息的特征?
报表的几种常见形式



学习目标
核心技术分析:
相关技术--无框架报表生成:
三个疑问?
后台数据抽取
数据项逻辑运算
前台展示

后台数据抽取
数据项逻辑运算
前台展示

(原生态JAVA生成报表实例讲解)
实例讲解:案例描述
一家经营数码产品的网店需要一张报表来分析经营情况;
利润表

案例数据库结构
(数据库共三张表)
商品信息表

卖家信息表


效果图

3.创建模型
package beans;/**** @author Wangqinggang* @version 1.0.0* @since* 创建时间:2017年5月12日* 功能描述:* 官方网站:www.study821.com* 邮箱地址:599255294@qq.com*/public class Goods {//商品Idprivate int goodsId;//商品名称private String goodsName;//成本价private String costPrice;//售价private String sellingPrice;//制造商private String manufacturer;/*** @return the goodsId*/public int getGoodsId() {return goodsId;}/*** @param goodsId the goodsId to set*/public void setGoodsId(int goodsId) {this.goodsId = goodsId;}/*** @return the goodsName*/public String getGoodsName() {return goodsName;}/*** @param goodsName the goodsName to set*/public void setGoodsName(String goodsName) {this.goodsName = goodsName;}/*** @return the costPrice*/public String getCostPrice() {return costPrice;}/*** @param costPrice the costPrice to set*/public void setCostPrice(String costPrice) {this.costPrice = costPrice;}/*** @return the sellingPrice*/public String getSellingPrice() {return sellingPrice;}/*** @param sellingPrice the sellingPrice to set*/public void setSellingPrice(String sellingPrice) {this.sellingPrice = sellingPrice;}/*** @return the manufacturer*/public String getManufacturer() {return manufacturer;}/*** @param manufacturer the manufacturer to set*/public void setManufacturer(String manufacturer) {this.manufacturer = manufacturer;}}
/*** Users.java* Version 1.0.0* Created on 2017年5月12日* Copyright Wangqingang**/package beans;/*** @author Wangqinggang* @version 1.0.0* @since* 创建时间:2017年5月12日* 功能描述:* 官方网站:www.study821.com* 邮箱地址:599255294@qq.com*/public class Users {//卖家IDprivate int userId;//卖家姓名private int userName;//买家年龄private int age;//卖家性别private String sex;//卖家所在地区private String area;//卖家电话private int number;/*** @return the userId*/public int getUserId() {return userId;}/*** @param userId the userId to set*/public void setUserId(int userId) {this.userId = userId;}/*** @return the userName*/public int getUserName() {return userName;}/*** @param userName the userName to set*/public void setUserName(int userName) {this.userName = userName;}/*** @return the age*/public int getAge() {return age;}/*** @param age the age to set*/public void setAge(int age) {this.age = age;}/*** @return the sex*/public String getSex() {return sex;}/*** @param sex the sex to set*/public void setSex(String sex) {this.sex = sex;}/*** @return the area*/public String getArea() {return area;}/*** @param area the area to set*/public void setArea(String area) {this.area = area;}/*** @return the number*/public int getNumber() {return number;}/*** @param number the number to set*/public void setNumber(int number) {this.number = number;}}
/*** TradingInf.java* Version 1.0.0* Created on 2017年5月12日* Copyright Wangqingang**/package beans;/*** @author Wangqinggang* @version 1.0.0* @since* 创建时间:2017年5月12日* 功能描述:* 官方网站:www.study821.com* 邮箱地址:599255294@qq.com*/public class TradingInf {//交易IDprivate String tradingId;//交易商品IDprivate int tradingGoodsId;//交易卖家IDprivate int tradingUserID;//交易数量private int tradingNumber;/*** @return the tradingId*/public String getTradingId() {return tradingId;}/*** @param tradingId the tradingId to set*/public void setTradingId(String tradingId) {this.tradingId = tradingId;}/*** @return the tradingGoodsId*/public int getTradingGoodsId() {return tradingGoodsId;}/*** @param tradingGoodsId the tradingGoodsId to set*/public void setTradingGoodsId(int tradingGoodsId) {this.tradingGoodsId = tradingGoodsId;}/*** @return the tradingUserID*/public int getTradingUserID() {return tradingUserID;}/*** @param tradingUserID the tradingUserID to set*/public void setTradingUserID(int tradingUserID) {this.tradingUserID = tradingUserID;}/*** @return the tradingNumber*/public int getTradingNumber() {return tradingNumber;}/*** @param tradingNumber the tradingNumber to set*/public void setTradingNumber(int tradingNumber) {this.tradingNumber = tradingNumber;}}
/*** Profit.java* Version 1.0.0* Created on 2017年5月12日* Copyright Wangqingang**/package beans;/*** @author Wangqinggang* @version 1.0.0* @since* 创建时间:2017年5月12日* 功能描述:* 官方网站:www.study821.com* 邮箱地址:599255294@qq.com*/public class Profit {//商品名称private String goodsName;//商品Idprivate int goodsId;//成本价private int costPrice;//售价private int sellingPrice;//交易数量private int tradingNum;//交易数量private int times;/*** @return the goodsName*/public String getGoodsName() {return goodsName;}/*** @param goodsName the goodsName to set*/public void setGoodsName(String goodsName) {this.goodsName = goodsName;}/*** @return the goodsId*/public int getGoodsId() {return goodsId;}/*** @param goodsId the goodsId to set*/public void setGoodsId(int goodsId) {this.goodsId = goodsId;}/*** @return the costPrice*/public int getCostPrice() {return costPrice;}/*** @param costPrice the costPrice to set*/public void setCostPrice(int costPrice) {this.costPrice = costPrice;}/*** @return the sellingPrice*/public int getSellingPrice() {return sellingPrice;}/*** @param sellingPrice the sellingPrice to set*/public void setSellingPrice(int sellingPrice) {this.sellingPrice = sellingPrice;}/*** @return the tradingNum*/public int getTradingNum() {return tradingNum;}/*** @param tradingNum the tradingNum to set*/public void setTradingNum(int tradingNum) {this.tradingNum = tradingNum;}/*** @return the times*/public int getTimes() {return times;}/*** @param times the times to set*/public void setTimes(int times) {this.times = times;}/*** @return the profit*/public int getProfit() {return profit;}/*** @param profit the profit to set*/public void setProfit(int profit) {this.profit = profit;}private int profit;}
/*** JdbcConn.java* Version 1.0.0* Created on 2017年5月12日* Copyright Wangqingang**/package jdbc;import java.sql.Connection;import java.sql.DriverManager;import java.sql.PreparedStatement;import java.sql.ResultSet;import java.sql.SQLException;import java.sql.Statement;import com.sun.corba.se.spi.orbutil.fsm.Guard.Result;/*** @author Wangqinggang* @version 1.0.0* @since* 创建时间:2017年5月12日* 功能描述:* 官方网站:www.study821.com* 邮箱地址:599255294@qq.com*/public class JdbcConn {private static String url="jdbc:oracle:thin:@localhost:1521:orcl";private static String user="muke";private static String password ="muke";public static Connection conn;public static PreparedStatement ps;public static ResultSet rs;public static Statement st;public static Connection getConnection(){try {Class.forName("oracle.jdbc.driver.OracleDriver");try {conn=DriverManager.getConnection(url,user,password);} catch (SQLException e) {// TODO Auto-generated catch blocke.printStackTrace();}} catch (Exception e) {// TODO Auto-generated catch blocke.printStackTrace();}return conn;}}
补充:java注释:
在Eclipse中怎样写Java注释
Eclipse Java注释模板设置详解