自己写的一个简单的购物系统,刷新总是追加记录~~求高手解决!
问题是:购买一次以后,在当前浏览器 F5 刷新后总是自动追加记录.
目前分析是jsp的代码问题。
测试软件:tomcat-5.5
jsp源代码如下:
<%@page contentType= "text/html;charset=gb2312 " %>
<%@page import= "shop.*,java.util.* " %>
<html>
<head>
<title> 手机大甩卖 </title>
</head>
<body>
<center>
<h1> 欢迎购物 </h1>
<form action= "/mvc2/zhang/shopservlet " name= "show " value= "add " method= "post ">
<select name= "Favorite ">
<option> 三星|韩国|银白|$1 </option>
<option> 三星|韩国|银白|$2 </option>
<option> 三星|韩国|银白|$3 </option>
<option> 三星|韩国|银白|$4 </option>
<option> 三星|韩国|银白|$3 </option>
<option> 三星|韩国|银白|$2 </option>
</select>
数量 <input type= "text " name= "buy " size= "3 ">
<input type= "hidden " name= "cmd " value= "add ">
<input type= "submit " value= "购买 ">
</form>
<%
Vector vector = (Vector)session.getAttribute( "total ");
if(vector!=null && vector.size()> =0){
%>
<table bgcolor= "#238734 " border= "2 " width= "50% ">
<tr>
<td> 产品名 </td>
<td> 产地 </td>
<td> 颜色 </td>
<td> 单价 </td>
<td> 数量 </td>
</tr>
<%
for(int index=0;index <vector.size();index++){
ShopBean sh = (ShopBean)vector.elementAt(index);
%>
<tr>
<td> <%=sh.getName()%> </td>
<td> <%=sh.getCountry()%> </td>
<td> <%=sh.getColor()%> </td>
<td> <%=sh.getPrice()%> </td>
<td> <%=sh.getNumber()%> </td>
<form action= "/mvc2/zhang/shopservlet " name= "shop " method= "post ">
<td>
<input type= "submit " name= "sumbit " value= "删除 " size= "5 ">
<input type= "hidden " name= "cmd " value= "delect ">
<input type= "hidden " name= "del " value= " <%=index%> ">
</td>
</form>
<td> <%=index%> , <%=vector.size() %> </td>
</tr>
<% } %>
</table>
<% String money = (String)request.getAttribute( "count ");%>
<% if(money!=null){%>
<td> 总金额:
<