网上书城java项目代码,网上书城java项目代码是多少
用java编写一个电子书店程序
悬赏什么的不值钱的,没人愿意花时间做这个的,推荐CSDN网站自己找找类似的,然后改改,如果改的能力都没有的话,那也就没办法了
创新互联于2013年创立,先为商南等服务建站,商南等地企业,进行企业商务咨询服务。为商南企业网站制作PC+手机+微官网三网同步一站式服务解决您的所有建站问题。
求Java语言为书城设计一个简单购物车类。
public class ShoppingCart {//购物车类
private Producted prod;//商品类,存放商品信息
private int num;//商品数量
public Producted getProd() {
return prod;
}
public void setProd(Producted prod) {
this.prod = prod;
}
public int getNum() {
return num;
}
public void setNum(int num) {
this.num = num;
}
}
public class Producted {//商品类
private String prodName;//商品名称
private Double marketPrice;//市场价
private Double sellPrice;//本店价
private Double save;//优惠
private Short points;//积分
public String getProdName() {
return prodName;
}
public void setProdName(String prodName) {
this.prodName = prodName;
}
public Double getMarketPrice() {
return marketPrice;
}
public void setMarketPrice(Double marketPrice) {
this.marketPrice = marketPrice;
}
public Double getSellPrice() {
return sellPrice;
}
public void setSellPrice(Double sellPrice) {
this.sellPrice = sellPrice;
}
public Double getSave() {
return save;
}
public void setSave(Double save) {
this.save = save;
}
public Short getPoints() {
return points;
}
public void setPoints(Short points) {
this.points = points;
}
}
有用请采纳
某网上书城可以查询、删除书籍,现要求使用JSP实现该功能
简单的增删改查功能
package EBookDao;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import DBUtil.DBUtil;
import DBUtil.EBook;
/*
*查询书集信息
*
* */
public class EBookCZ {
public ListEBook find() {
Connection conn = null;
PreparedStatement ps = null;
ResultSet rs = null;
ListEBook list = new ArrayListEBook();
try {
conn = DBUtil.getConnection();
String sql = "SELECT * FROM ebook";
ps = conn.prepareStatement(sql);
rs = ps.executeQuery();
while (rs.next()) {
EBook eBook = new EBook();
eBook.setId(rs.getInt("ID"));
eBook.setBname(rs.getString("bname"));
eBook.setPrice(rs.getString("price"));
list.add(eBook);
System.out.println(rs.getInt("ID")+rs.getString("bname")+rs.getString("price"));
}
} catch (SQLException sqle) {
sqle.printStackTrace();
} finally {
DBUtil.close(conn, ps, rs);
}
return list;
}
/*
*通过id删除书集信息
*
* */
public static EBook DelById(int id) {
Connection conn = null;
PreparedStatement ps = null;
ResultSet rs = null;
EBook book = null;
try {
conn = DBUtil.getConnection();
String sql = "delete ebook ";
sql += "WHERE ID=? ";
ps = conn.prepareStatement(sql);
ps.setInt(1, id);
rs = ps.executeQuery();
if (rs.next()) {
book = new EBook();
book.setId(rs.getInt("ID"));
book.setBname(rs.getString("bname"));
book.setPrice(rs.getString("price"));
}
} catch (SQLException sqle) {
sqle.printStackTrace();
} finally {
DBUtil.close(conn, ps, rs);
}
return book;
}
}
package EBookServlet;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import DBUtil.EBook;
import EBookDao.EBookCZ;
public class EBookServlet extends HttpServlet {
/**
*
*/
private static final long serialVersionUID = 1L;
/**
* Constructor of the object.
*/
public EBookServlet() {
super();
}
/**
* Destruction of the servlet. br
*/
public void destroy() {
super.destroy(); // Just puts "destroy" string in log
// Put your code here
}
/**
* The doGet method of the servlet. br
*
* This method is called when a form has its tag value method equals to get.
*
* @param request
* the request send by the client to the server
* @param response
* the response send by the server to the client
* @throws ServletException
* if an error occurred
* @throws IOException
* if an error occurred
*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
this.doPost(request, response);
}
/**
* The doPost method of the servlet. br
*
* This method is called when a form has its tag value method equals to
* post.
*
* @param request
* the request send by the client to the server
* @param response
* the response send by the server to the client
* @throws ServletException
* if an error occurred
* @throws IOException
* if an error occurred
*/
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=utf-8");
PrintWriter out = response.getWriter();
String method = request.getParameter("method");
String url = "";
EBookCZ bookCZ=new EBookCZ();
if (method != null method.equals("find")) {
System.out.println("find做完了");
url = "EBookMNG.jsp";
ListEBook list = bookCZ.find();
request.setAttribute("list", list);
} else if (method != null method.equals("findById")) {
System.out.println("findbyid做完了");
url = "OK.jsp";
int id = Integer.parseInt(request.getParameter("id"));
EBook book = EBookCZ.DelById(id);
request.setAttribute("book", book);
}
request.getRequestDispatcher(url).forward(request, response);
out.flush();
out.close();
}
/**
* Initialization of the servlet. br
*
* @throws ServletException
* if an error occurs
*/
public void init() throws ServletException {
// Put your code here
}
}
网页题目:网上书城java项目代码,网上书城java项目代码是多少
分享路径:http://myzitong.com/article/hchscd.html