Jsp动态网站初步项目 --简单的商品浏览页面(商品浏览页面index.jsp)

来源:互联网 发布:我做淘宝在哪找货源 编辑:程序博客网 时间:2024/06/06 13:02
<%@ page language="java" import="java.util.*" contentType="text/html; charset=utf-8"%><%@ page import = "com.dao.ItemDAO" %><%@ page import = "com.bean.Item" %><%String path = request.getContextPath();String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html>  <head>    <base href="<%=basePath%>">        <title>My JSP 'index.jsp' starting page</title><meta http-equiv="pragma" content="no-cache"><meta http-equiv="cache-control" content="no-cache"><meta http-equiv="expires" content="0">    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"><meta http-equiv="description" content="This is my page"><!--<link rel="stylesheet" type="text/css" href="styles.css">--><style type="text/css">     div   {      float: left;          margin: 10px;       }    div dd    {          margin: 0px;          font-size: 10pt;        }    div dd.dd_name    {      color: blue;    }          div dd.dd_city    {      color:#000;    }</style>  </head>    <body>    <h1>商品展示</h1>    <hr/>     <center>       <table width="750" height="60" cellpadding="0" cellspacing="0" border="0">       <tr>         <td>         <!-- 商品循环开始 -->        <%              ItemDAO dao = new ItemDAO();             ArrayList<Item> items = dao.getAllitems();           //  out.println("商品数目:"+items.size());             if(items!=null&&items.size()>0)             {                for(Item item:items)                {        %>           <div>             <dl>                  <dt>                    <a href="details.jsp?id=<%=item.getId() %>"> <img src="image/<%=item.getImage()%>" width="120" height="120"> </a>                 </dt>                 <dd class="dd_name">名称:<%=item.getName() %></dd>                 <dd class="dd_city"> 产地 :<%=item.getCity() %>   价格:¥<%=item.getPrice() %></dd>                          </dl>           </div>           <%                  }               }            %>           <!-- 商品循环结束 -->                    </td>       </tr>                      </table>     </center>  </body></html>

0 0
原创粉丝点击