• 大小: 5.9MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-09-23
  • 语言: 其他
  • 标签: sh  

资源简介

网上书城onlineBookStore+struts+hibernate

资源截图

代码片段和文件信息

package com.onlineBookStore.action;

import java.io.IOException;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import net.sf.json.JSONArray;
import net.sf.json.JSONobject;

import org.apache.struts2.ServletActionContext;

import com.onlineBookStore.pojo.BookCar;
import com.onlineBookStore.pojo.Bookinfo;
import com.onlineBookStore.pojo.Order;
import com.onlineBookStore.pojo.Userinfo;
import com.onlineBookStore.service.BookinfoService;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

public class BookCarAction extends ActionSupport {

/**
 * 
 */
private static final long serialVersionUID = 3320254023162195908L;
private int bookId;
// private Map cookie;
private BookinfoService bs = new BookinfoService();
private int remaining;
  
public void addBookCar() throws Exception {
ActionContext context = ActionContext.getContext();
HttpServletResponse response = (HttpServletResponse) context
.get(ServletActionContext.HTTP_RESPONSE);
HttpServletRequest request = (HttpServletRequest) context
.get(ServletActionContext.HTTP_REQUEST);
String msg = null;
Mapject> session = context.getSession();

Bookinfo book = bs.getBookById(bookId);
List bookCars = (List) session.get(“bookCars“);
if (book.getRemaining() > 0&&bs.deleteBookRemaining(book)) {
BookCar bookCar=new BookCar();
bookCar.setBookId(book.getId());
bookCar.setBookName(book.getBookName());
bookCar.setBookNumber(1);
bookCar.setWriter(book.getWriter());
bookCar.setPrice(book.getPrice());
boolean temp = false;
if (bookCars == null) {
bookCars = new ArrayList();
bookCars.add(bookCar);
} else {
for (int i = 0; i < bookCars.size(); i++) {
if (bookCar.getBookId() == bookCars.get(i).getBookId()) {
bookCars.get(i).setBookNumber(
bookCars.get(i).getBookNumber() + 1);
temp = true;
break;
}
}
if(temp==false){
bookCars.add(bookCar);
}

}
session.put(“bookCars“ bookCars);
msg=“已添加到购物车“;
}else {
msg = “该图书暂时无货“;
}
// int bookid=book.getId();
// System.out.println(bookCar);
response.setContentType(“text/html; charset=utf-8“);

response.getWriter().write(msg);

response.getWriter().flush();
response.getWriter().close();

}

public void addBookCar_1() throws Exception {

ActionContext context = ActionContext.getContext();
HttpServletResponse response = (HttpServletResponse) context
.get(ServletActionContext.HTTP_RESPONSE);
HttpServletRequest request = (HttpServletReques

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       1386  2014-11-16 15:58  onlineBookStore\.classpath

     文件        486  2014-11-20 17:11  onlineBookStore\.myhibernatedata

     文件       1340  2014-11-16 16:06  onlineBookStore\.project

     文件        522  2014-11-16 15:43  onlineBookStore\.settings\.jsdtscope

     文件         69  2014-11-22 18:32  onlineBookStore\.settings\org.eclipse.core.resources.prefs

     文件        364  2014-11-16 15:43  onlineBookStore\.settings\org.eclipse.jdt.core.prefs

     文件        504  2014-11-16 15:43  onlineBookStore\.settings\org.eclipse.wst.common.component

     文件        465  2014-11-16 15:58  onlineBookStore\.settings\org.eclipse.wst.common.project.facet.core.xml

     文件         49  2014-11-16 15:43  onlineBookStore\.settings\org.eclipse.wst.jsdt.ui.superType.container

     文件          6  2014-11-16 15:43  onlineBookStore\.settings\org.eclipse.wst.jsdt.ui.superType.name

     文件       6585  2014-12-11 17:11  onlineBookStore\src\com\onlineBookStore\action\BookCarAction.java

     文件       6149  2014-11-29 20:41  onlineBookStore\src\com\onlineBookStore\action\BookinfoAction.java

     文件       1248  2014-11-29 17:05  onlineBookStore\src\com\onlineBookStore\action\OrderAction.java

     文件       3028  2014-11-30 15:52  onlineBookStore\src\com\onlineBookStore\action\RemarkAction.java

     文件       4264  2014-12-10 20:54  onlineBookStore\src\com\onlineBookStore\action\SearchBookAction.java

     文件       3959  2014-11-29 17:05  onlineBookStore\src\com\onlineBookStore\action\UserinfoAction.java

     文件       1011  2014-11-21 11:50  onlineBookStore\src\com\onlineBookStore\cfg\Addressinfo.hbm.xml

     文件       2410  2014-11-28 16:25  onlineBookStore\src\com\onlineBookStore\cfg\Bookinfo.hbm.xml

     文件       1474  2014-11-21 11:48  onlineBookStore\src\com\onlineBookStore\cfg\Order.hbm.xml

     文件       1186  2014-11-21 11:50  onlineBookStore\src\com\onlineBookStore\cfg\Remark.hbm.xml

     文件       1639  2014-11-22 17:30  onlineBookStore\src\com\onlineBookStore\cfg\Userinfo.hbm.xml

     文件       3988  2014-11-29 17:05  onlineBookStore\src\com\onlineBookStore\dao\AddressinfoDAO.java

     文件        381  2014-11-29 17:05  onlineBookStore\src\com\onlineBookStore\dao\baseHibernateDAO.java

     文件       3892  2014-11-29 17:05  onlineBookStore\src\com\onlineBookStore\dao\BookinfoDAO.java

     文件        237  2014-11-29 17:05  onlineBookStore\src\com\onlineBookStore\dao\IbaseHibernateDAO.java

     文件       3798  2014-11-29 17:05  onlineBookStore\src\com\onlineBookStore\dao\OrderDAO.java

     文件       3828  2014-11-29 17:05  onlineBookStore\src\com\onlineBookStore\dao\RemarkDAO.java

     文件       3892  2014-11-29 17:05  onlineBookStore\src\com\onlineBookStore\dao\UserinfoDAO.java

     文件       1264  2014-11-20 17:12  onlineBookStore\src\com\onlineBookStore\pojo\Addressinfo.java

     文件        821  2014-12-11 14:27  onlineBookStore\src\com\onlineBookStore\pojo\BookCar.java

............此处省略123个文件信息

评论

共有 条评论