《JavaEE结课大作业》模板样例
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
内蒙古科技大学《JavaEE结课大作业》报告
姓名:
专业:计算机12级2班
学号:
完成日期:2015年 7 月8日
图书商城系统的实现一、运行界面截图
首页:
图书信息展示:
根据图书id查看某个图书详情:
根据图书id删除图书:根据id修改图书信息:
添加图书:
二、核心代码说明
查看所有图书信息:package com.ly.action; import java.util.List;
import java.util.Map;
import org.apache.struts2.interceptor.RequestAware;
import com.ly.bean.LyBook;
import com.ly.service.LyBookSer;
public class LyBookAction implements RequestAware { private LyBookSer BookSer;
private int sencond;
private int first;
private int bookid;
public void setBookid(int bookid) {
this.bookid = bookid;
}
public void setFirst(int first) {
this.first = first;
}
public void setSencond(int sencond) {
this.sencond = sencond;
}
public void setBookSer(LyBookSer bookSer) { BookSer = bookSer;
}
public String getAll(){
List<LyBook> list = BookSer.getAll();
map.put("booklist", list);
return "success";
}
private Map<String, Object> map;
public void setRequest(Map<String, Object> arg0) {
this.map = arg0;
}
根据图书id查看:
public String detail(){
map.clear();
BookSer.detail(bookid);
List<LyBook> list = BookSer.detail(bookid);
map.put("booklist", list);
return"detail";
}
}
public List<LyBook> detail(int id){
String sql="from LyBook where bookid= "+id;
List<LyBook> list =(List<LyBook>) getsSession().createQuery(sql).list();
return list;
}
public List<LyBook> detail(int bookid){ return Bookdao.detail(bookid);
}
根据ID删除:
private int bookid;
public void setBookid(int bookid) {
this.bookid = bookid;
}
public String delete(){
BookSer.delete(bookid);
return"delete";
}
public void delete(int bookid){
Bookdao.delete(bookid);
}
public void delete(int bookid){
String sql="delete from LyBook where bookid=?";
getsSession().createQuery(sql).setInteger(0,
bookid).executeUpdate();
}
根据id修改图书信息:
public String update1(){
BookSer.detail(bookid);
List<LyBook> list = BookSer.detail(bookid);
map.put("booklist", list);
return"update";
}
public String update(){
BookSer.update(bookid, price, bookname, conutNum, author);
return"delete";
}
public void update(int bookid,double price,String bookname,int conutNum,String author){
String sql="update LyBook set price="+price+"where bookid="+bookid;
getsSession().createQuery(sql).executeUpdate();
}
添加图书:
public void addbook(LyBook book){
getsSession().saveOrUpdate(book);
}
public void addbook(LyBook book){
Bookdao.addbook(book);
}
}
private String bookname;
private int conutNum;
private double price;
private String author;
public void setBookname(String bookname) { this.bookname = bookname;
}
public void setPrice(double price) {
this.price = price;
}
public void setAuthor(String author) { this.author = author;
}
public void setConutNum(int conutNum) { this.conutNum = conutNum;
}
public String addbook(){
LyBook book = new LyBook();
book.setBookname(bookname);
book.setConutNum(conutNum);
book.setPrice(price);
book.setAuthor(author);
BookSer.addbook(book);
return"delete";
}
}三、附:项目代码压缩包上传至教学平台。