思维导图
?新书上架 dao和Action
①dao ?根据时间降序
//新书上架 ? ? public List<Book> news(Book book,PageBean pageBean) throws Exception { ? ? ? ? String sql="select * from t_easyui_book where state=2 order by deployTime desc limit 8"; ? ? ? ? return super.executeQuery(sql, Book.class, pageBean); ? ? }
②Action
public void news(HttpServletRequest req, HttpServletResponse resp) { ? ? ? ? try { ? ? ? ? ? ? List<Book> list = bookDao.news(book, null); ? ? ? ? ? ? ResponseUtil.writeJson(resp, list); ? ? ? ? } catch (Exception e) { ? ? ? ? ? ? e.printStackTrace(); ? ? ? ? } ? ? }
index.jsp界面 ?
调用news方法进行跳转
$(function () {
// 上架新书
$.ajax({
url: '${pageContext.request.contextPath}/book.action?methodName=news',
dataType: "json",
data: "rows=18",
success: function (data) {
// data = eval(data);
// $(".c-category").next().append("444");
console.log(data);
single_item($(".c-category:eq(0)"), data, 0, "");
// debugger;
}
});
界面展示
?热门书籍 dao和Action
①dao
//热门书籍 ? ? ? ? public List<Book> hots(Book book,PageBean pageBean) throws Exception { ? ? ? ? ? ? String sql="select * from t_easyui_book where state=2 order by sales desc limit 8"; ? ? ? ? ? ? return super.executeQuery(sql, Book.class, pageBean); ? ? ? ? } ? ??
②Action
public void hots(HttpServletRequest req, HttpServletResponse resp) { ? ? ? ? try { ? ? ? ? ? ? List<Book> list = bookDao.hots(book, null); ? ? ? ? ? ? ResponseUtil.writeJson(resp, list); ? ? ? ? } catch (Exception e) { ? ? ? ? ? ? e.printStackTrace(); ? ? ? ? } ? ? } index.jsp界面进行跳转
// 热销书籍
$.ajax({
url: '${pageContext.request.contextPath}/book.action?methodName=hots',
dataType: "json",
data: "rows=18",
success: function (data) {
// data = eval(data);
// $(".c-category").next().append("444");
console.log(data);
single_item($(".c-category:eq(1)"), data, 0, "");
// debugger;
}
});
结果展示
?
|