《电子商务网站开发与设计》课程设计
}
public List findSaleGoods() { }
Session session=null; ArrayList al=new ArrayList(); try { session=HibernateSessionFactory.getSession(); Query query=session.createQuery(\al=(ArrayList)query.list(); } catch (HibernateException e) { // TODO Auto-generated catch block e.printStackTrace(); }finally{ } return al; session.close(); 3.2.2 分层结构和文件调用关系 首先,由JSP页面发出请求查找saleGoods,调用Action包里的getSaleGoods方法,该包会调用DaoImpl包里的findSaleGoods方法,查询数据库,找到特价商品的列表,保存进requese对象的saleGoods变量里,然后返回到saleGoods,显示到主页面。 3.3 畅销商品模块实现 3.3.1 模块功能实现和关键代码说明 9 《电子商务网站开发与设计》课程设计 代码如下: public String getHitGoods() throws Exception{ } public List findHitGoods() { Session session=null; ArrayList al=new ArrayList(); try { 开始 调用GoodsAction里的 getHitGoods方法 调用GoodsDaoImpl里的findHitGoods 方法查询数据库 结束 图3.1 畅销模块流程图(流程图例) GoodsDaoImpl gdao=new GoodsDaoImpl(); ArrayList hitGoods=(ArrayList)gdao.findHitGoods(); //将newGoods放入request对象 Map request=(Map)ActionContext.getContext().get(\request.put(\return \ session=HibernateSessionFactory.getSession(); 10 《电子商务网站开发与设计》课程设计 } Query query=session.createQuery(\al=(ArrayList)query.list(); } catch (HibernateException e) { // TODO Auto-generated catch block e.printStackTrace(); }finally{ } return al; session.close(); 3.3.2 分层结构和文件调用关系 首先,由JSP页面发出请求查找HitGoods,调用Action包里的getHitGoods方法,该包会调用DaoImpl包里的findHItGoods方法,查询数据库,找到畅销商品的列表,保存进requese对象的hitGoods变量里,然后返回到hitGoods,显示到主页面。 3.4 查看订单模块实现 3.4.1 模块功能实现和关键代码说明 调用OrderDaoImplfindOrderById方法 里的调用OrderAction里的findId方法 开始 结束 11 《电子商务网站开发与设计》课程设计 代码如下: public String findId() throws Exception{ } OrderDaoImpl odao=new OrderDaoImpl(); List Map request=(Map)ActionContext.getContext().get(\request.put(\request.put(\return \ 图3.1 查看订单模块流程图(流程图例) public List Session session=null; List session=HibernateSessionFactory.getSession(); Query query=session.createQuery(\query.setLong(0,id);//设置第一个问号 g=(List } catch (HibernateException e) { // TODO Auto-generated catch block e.printStackTrace(); }finally{ } 12 session.close();
相关推荐: