• 小项目第二天图书的现实完成


    servlet的代码:

    /查找图书的集合
    public String findAll(HttpServletRequest req, HttpServletResponse resp)
    throws ServletException, IOException {
    req.setAttribute("bookList", bookService.findAll());//将bookList对象保存到request域中
    return "f:/jsps/book/list.jsp";//转发到list.jsp页面上
    }
    //按条件查询
    public String findByCategory(HttpServletRequest req, HttpServletResponse resp)
    throws ServletException, IOException {
    String cid=req.getParameter("cid");//拿到传输过来的id
    req.setAttribute("bookList", bookService.findByCategory(cid));//通过条件查询到书,并封装成bookList保存到request域中
    return "f:/jsps/book/list.jsp";//转发到list.jsp页面上
    }
    //按单本书查询
    public String load(HttpServletRequest req, HttpServletResponse resp)
    throws ServletException, IOException {
    String bid=req.getParameter("bid");//拿到传输过来的id
    req.setAttribute("book", bookService.load(bid));//通过条件查询到书,并封装成book保存到request域中
    return "f:/jsps/book/desc.jsp";//转发到desc.jsp页面上
    }

    jsp的一些代码:

    <c:forEach items="${bookList }" var="book">
      <div class="icon">
        <a href="<c:url value='/BookServlet?method=load&bid=${book.bid}'/>"><img src="<c:url value='/${book.image }'/>" border="0"/></a>
          <br/>
        <a href="<c:url value='/BookServlet?method=load&bid=${book.bid}'/>">${book.bname}</a>
      </div>
      </c:forEach>

  • 相关阅读:
    关于开发BugRaid的想法(2)
    杭州.net俱乐部第一次见面会情况
    关于Bug管理的过程
    关于开发BugRaid的想法(1)
    变态的VS2005 SP1
    vs2003 sp1 download url
    proxy software
    敏捷开发
    Enterprise Library文档
    ETL
  • 原文地址:https://www.cnblogs.com/csnd/p/16675719.html
Copyright © 2020-2023  润新知