qq__3590
2017-01-21 15:08
<%@page import="java.util.ArrayList"%>
<%@page import="com.entity.Items"%>
<%@page import="com.dao.ItemsDao"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>商品详情</title>
<style type="text/css">
div{
float: left;
margin: 5px 30px;
}
div dd{
margin: 0px;
font-size: 10pt;
}
div dd dd_name{
color: blue;
}
div dd dd_city{
color: #000;
}
</style>
</head>
<body>
<h1>商品详情</h1>
<center>
<table width="750" height="60" cellpadding="0" cellspacing="0" border="0">
<tr>
<!-- 商品详情 -->
<%
ItemsDao itemsDao = new ItemsDao();
Items items = itemsDao.getOne(Integer.parseInt(request.getParameter("id")));
if(items!=null){
%>
<td width="70%">
<table>
<tr>
<td rowspan="4"><img alt="" src="images/<%=items.getPicture() %>>" width="200px" height="150px"></td>
</tr>
<tr>
<td><%=items.getName() %></td>
</tr>
<tr>
<td>产地:<%=items.getCity() %></td>
</tr>
<tr>
<td>价格:¥<%=items.getPrice() %></td>
</tr>
</table>
</td>
<%
}
%>
<%
String list="";
//从客户端获得Cookies集合
Cookie[] cookies = request.getCookies();
//遍历cookies集合
if(cookies!=null&&cookies.length>0){
for(Cookie c : cookies){
if(c.getName().equals("ListViewCookie")){
list = c.getValue();
}
}
}
list+=request.getParameter("id")+"x";
//如果浏览记录超过10条,自动清零
String[] arr = list.split("x");
if(arr!=null&&arr.length>0){
if(arr.length>=10){
list=" ";
}
}
Cookie cookie = new Cookie("ListViewCookie",list);
response.addCookie(cookie);
%>
<!-- 浏览过的商品 -->
<td width="30%" background="#EEE" align="center">
<p>您浏览过的商品</p>
<!-- 循环开始 -->
<%
ArrayList<Items> itemList = itemsDao.getViewList(list);
if(itemList!=null&&itemList.size()>0){
System.out.println("itemList.size="+itemList.size());
for(Items i : itemList){
%>
<div>
<dl>
<dt>
<a href="detail.jsp?id=<%=i.getId()%>"><img alt="" src="images/<%=i.getId() %>" width="150px" height="100px" border="1"></a>
</dt>
<dd class="dd_name"><%=i.getName() %></dd>
<dd class="dd_city">城市:<%=i.getCity() %> 价格:¥<%=i.getPrice() %></dd>
</dl>
</div>
<%
}
}
%>
<!-- 循环结束 -->
</td>
</tr>
</table>
</center>
</body>
</html>
请问这是为什么?
数组越界
JAVA遇见HTML——JSP篇
248276 学习 · 3198 问题
相似问题