0hi猿团提供了移动跨平台开发视频,包括html5,apicloud appcan,dcloud,具体请看http://www.9y.cm
实现查找一个东西 完整得代码如下:
一个jsp显示页面:
<center>
<br><br>
<table cellpadding="10">
<c:forEach items="${requestScope.cn_itcast_bookstore_catalog_books}" var="book">
<tr>
<td><a href="bookDetailServlet?bookId=${book.id }"><c:out value="${book.title}"></c:out></a><br>
<c:out value="${book.author}"></c:out>
</td>
<td><c:out value="${book.price}"></c:out> </td>
<td><a href="">加入购物车</a>
</tr>
</c:forEach>
</table>
</center>
一个BookDetailServlet类来实现控制:bookDetailservlet。java
public class BookDetailServlet extends HttpServlet {
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
String bookId =request.getParameter("bookId");
System.out.println(bookId);
BookService bookService =new BookService();
String forwardPage =null;
try {
Book book =bookService.getBookById(Integer.parseInt(bookId));
request.setAttribute(BookStoreGlobals.CN_ITCAST_BOOKSTORE_KEY_BOOKDETATL_BOOK, book);
forwardPage ="/WEB-INF/jsp/bookdetail.jsp";
} catch (NumberFormatException e) {
// TODO Auto-generated catch block
e.printStackTrace();
request.setAttribute(BookStoreGlobals.CN_ITCAST_BOOKSTORE_KEY_ERROR_INFO,
BookStoreGlobals.CN_ITCAST_BOOKSTORE_EXCETION_PARAM_NOT_INTEGET);
forwardPage="/WEB-INF/jsp/error.jsp";
}catch (Exception ex) {
request.setAttribute(BookStoreGlobals.CN_ITCAST_BOOKSTORE_KEY_ERROR_INFO, ex.getMessage());
forwardPage="/WEB-INF/jsp/error.jsp";
// TODO: handle exception
}
request.getRequestDispatcher(forwardPage).forward(request, response);
}
}
一个控制DAO得java页面
public Book getBookById(int bookId) {
// TODO Auto-generated method stub
Book book =null;
Connection conn =null;
conn =DBManager.getConnection();
BookDAO bookDAO =new BookDAO();
try {
book =bookDAO.queryBookByBookId(conn,bookId);
bookDAO= null;
} finally {
// TODO Auto-generated catch block
DBManager.closeConnection(conn);
}
return book;
}
DAO.java
public Book queryBookByBookId(Connection conn,int bookId) {
Book book =null;
String sql ="select * from mybooks where id =?";
Class clazz =Book.class;
Object[] params =new Object[]{bookId};
String expMsg =BookStoreGlobals.CN_ITCAST_BOOKSTORE_EXCETION_GET_BOOKS;
book =(Book) this.queryObject(conn, sql, params, clazz, expMsg);
return book;
}
以上是购物车得一个实例!