日期:2014-05-17  浏览次数:20700 次

关于Vector.add中的覆盖问题
<%@ page language="java" import="java.util.*" pageEncoding="gb2312"%>
<%
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 'showMsg.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">
-->

</head>

<body>
<%!Vector<String> list1 = new Vector<String>();
Vector<String> list2 = new Vector<String>();%>
<%
String title = request.getParameter("title");
String msg = request.getParameter("msg");
//list1.setSize(4);list2.setSize(4);

if (title != null && msg != null) {
list1.addElement(title);
list2.addElement(msg);
}
%>
<table border=1>
<tr>
<td>
留言者姓名
</td>
<td>
标题
</td>
<td>
留言
</td>
</tr>
<%
String name = (String) session.getAttribute("username");
for (int i = 0; i < list1.size(); i++)
out.print("<tr><td>" + name + (i + 1) + "</td><td>"
+ list1.elementAt(i) + "</td><td>" + list2.elementAt(i)
+ "</td></tr>");
%>
</table>
<br>
<a name="f" href="leaveMsg.jsp"> 返回继续留言</a>
<br>
</body>
</html>

------解决方案--------------------
我看你各vector只add过一次啊
------解决方案--------------------
貌似Vector不用了吧