Ejemplo n.º 1
0
 protected void doGet(HttpServletRequest request, HttpServletResponse response)
     throws ServletException, IOException {
   BookDao dao = new BookDao();
   if (request.getParameter("type") == null || request.getParameter("type").equals("全部类型")) {
     request.getSession().setAttribute("queryBooks", dao.queryBook(null, BookDao.QUERY_BY_TYPE));
   } else {
     LinkedList<Book> list = dao.queryBook(request.getParameter("type"), BookDao.QUERY_BY_TYPE);
     request.getSession().setAttribute("queryBooks", list);
   }
   request.getSession().setAttribute("who", "book");
   request.getRequestDispatcher("/back_stage.jsp").forward(request, response);
   dao.giveBack();
 }
Ejemplo n.º 2
0
  public List<BookMarkVo> getUserBookSimilar(int user1, int user2) {
    BookDao bd = new BookDao();
    List<BookMarkVo> m1 = bd.getBookAndGradeByUserId(user1);
    List<BookMarkVo> m2 = bd.getBookAndGradeByUserId(user2);

    List<BookMarkVo> list = new ArrayList<BookMarkVo>();

    int i = 0;
    for (BookMarkVo bookMarkVo : m1) {
      if (Tribuscontains(m2, bookMarkVo)) {
        i++;
        list.add(bookMarkVo);
      }
    }
    return list;
  }
Ejemplo n.º 3
0
 public static void bindBook(String sql) {
   DefaultTableModel dtm =
       new DefaultTableModel() {
         @Override
         public boolean isCellEditable(int arg0, int arg1) {
           // TODO Auto-generated method stub
           return false; // 表中数据不能改
         }
       };
   dtm.addColumn("书籍ID");
   dtm.addColumn("图书");
   dtm.addColumn("出版社");
   dtm.addColumn("价格");
   dtm.addColumn("作者");
   dtm.addColumn("ISDN码");
   dtm.addColumn("条形码");
   dtm.addColumn("是否在库");
   BookDao dao = new BookDao();
   ArrayList<Book> list = dao.getAllBook(sql);
   for (Book book : list) {
     Vector vec = new Vector();
     int bkid = book.getBkid();
     String bkname = book.getBkname();
     String bkconcern = book.getBkconcern();
     String bkprice = book.getBkprice();
     String bkwriter = book.getBkwriter();
     String bkisdn = book.getBkisdn();
     String bkbarcord = book.getBkbarcord();
     int a = book.getBkstatus();
     String ee = (a == 1 ? "在库" : "不在库");
     vec.add(bkid);
     vec.add(bkname);
     vec.add(bkconcern);
     vec.add(bkprice);
     vec.add(bkwriter);
     vec.add(bkisdn);
     vec.add(bkbarcord);
     vec.add(ee);
     dtm.addRow(vec);
   }
   table.setModel(dtm);
 }
Ejemplo n.º 4
0
 protected void doPost(HttpServletRequest request, HttpServletResponse response)
     throws ServletException, IOException {
   String bookname = request.getParameter("bookname");
   byte[] bytes = bookname.getBytes("ISO-8859-1");
   bookname = new String(bytes, "UTF-8");
   HttpSession session = request.getSession();
   BookDao dao = new BookDao();
   LinkedList<Book> list = new LinkedList<>();
   LinkedList<Book> sessionkList = (LinkedList<Book>) session.getAttribute("queryBooks");
   if (sessionkList != null) {
     for (Book book : sessionkList) {
       if (book.getName().contains(bookname)) {
         list.add(book);
         break;
       }
     }
   }
   session.setAttribute("queryBooks", list);
   session.setAttribute("who", "book"); // 显示书
   request.getRequestDispatcher("/back_stage.jsp").forward(request, response);
   dao.giveBack();
 }
Ejemplo n.º 5
0
 public static void bindBook() {
   BookDao dao = new BookDao();
   ArrayList<Book> list = dao.getAllBook();
   DefaultTableModel dtm =
       new DefaultTableModel() {
         @Override
         public boolean isCellEditable(int row, int column) {
           // TODO Auto-generated method stub
           return false;
         }
       };
   dtm.addColumn("书籍ID");
   dtm.addColumn("图书");
   dtm.addColumn("出版社");
   dtm.addColumn("价格");
   dtm.addColumn("作者");
   dtm.addColumn("ISDN码");
   dtm.addColumn("条形码");
   dtm.addColumn("是否在库");
   for (Book book : list) {
     Vector vec = new Vector();
     int bkid = book.getBkid();
     String bkname = book.getBkname();
     String bkconcern = book.getBkconcern();
     String bkprice = book.getBkprice();
     String bkwriter = book.getBkwriter();
     String bkisdn = book.getBkisdn();
     String bkbarcord = book.getBkbarcord();
     int a = book.getBkstatus();
     String ee = (a == 1 ? "在库" : "不在库");
     vec.add(bkid);
     vec.add(bkname);
     vec.add(bkconcern);
     vec.add(bkprice);
     vec.add(bkwriter);
     vec.add(bkisdn);
     vec.add(bkbarcord);
     vec.add(ee);
     dtm.addRow(vec);
   }
   table.setModel(dtm);
   table.getColumnModel().getColumn(0).setMaxWidth(40);
   table.getColumnModel().getColumn(0).setMinWidth(40);
   table.getColumnModel().getColumn(1).setMaxWidth(220);
   table.getColumnModel().getColumn(1).setMinWidth(220);
   table.getColumnModel().getColumn(1).setPreferredWidth(220);
   table.getColumnModel().getColumn(2).setMaxWidth(130);
   table.getColumnModel().getColumn(2).setMinWidth(130);
   table.getColumnModel().getColumn(2).setPreferredWidth(130);
   table.getColumnModel().getColumn(3).setMaxWidth(50);
   table.getColumnModel().getColumn(3).setMinWidth(50);
   table.getColumnModel().getColumn(3).setPreferredWidth(50);
   table.getColumnModel().getColumn(4).setMaxWidth(220);
   table.getColumnModel().getColumn(4).setMinWidth(220);
   table.getColumnModel().getColumn(4).setPreferredWidth(220);
   table.getColumnModel().getColumn(5).setMaxWidth(130);
   table.getColumnModel().getColumn(5).setMinWidth(130);
   table.getColumnModel().getColumn(5).setPreferredWidth(130);
   table.getColumnModel().getColumn(6).setMaxWidth(130);
   table.getColumnModel().getColumn(6).setMinWidth(130);
   table.getColumnModel().getColumn(6).setPreferredWidth(130);
   table.getColumnModel().getColumn(7).setMaxWidth(90);
   table.getColumnModel().getColumn(7).setMinWidth(90);
   table.getColumnModel().getColumn(7).setPreferredWidth(90);
 }