日期:2014-05-19  浏览次数:20699 次

提交form表单action代码执行两次?!!!!!!!是struts2
问题很奇怪,测了下是在最后的form表单(句号那),只要迭代从后台传来的list的值就会让action代码执行两次

<%@ page language="java" import="com.sykjw.entity.*,java.util.*,com.sykjw.vo.BasketFee" pageEncoding="utf-8"%>

<%@ taglib uri="/struts-tags" prefix="s" %>

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>

 <base href="<%=basePath%>">
  <title> New Document </title>

   <meta http-equiv="pragma" content="no-cache" charset=UTF-8"> 
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">    
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
 
<script type="text/javascript">

function dinggou(id,type){
var a = "#goods"+id ;
var type = type ;
var amount ;
var url ;
if(type == "1"){ //点击订购button触发

alert(type) ;
amount = $("#goods"+id).attr("value");
url = 'json/addGoods.action' ;

}
var req = {
"id":id,
"amount":amount,
}; 

//var params = Form.serialize('form1');
//创建Ajax.Request对象,对应于发送请求
$.post(url,req,function processResponse(date){

alert("回调函数1") ;
var  string = "<h3 id='goback' style='cursor:pointer'>我的购物车</h3>"
 +" <font style='color:blue'>提醒:根据你最终提交订单时间,订餐时间可能有所调整</font>"
 + "<table width='100%' border='1' style='border:1px solid #FFB31D' height='auto' cellpadding='0' cellspacing='0'>"
 + " <tr ><th scope='col' style='border-bottom:1px solid #FFB31D'>品名</th>"
 + "<th scope='col' style='border-bottom:1px solid #FFB31D'>数量(份)</th>"
 + "<th scope='col' style='border-bottom:1px solid #FFB31D'>价格(元)</th>"
 + "<th scope='col' style='border-bottom:1px solid #FFB31D'>取消</th></tr>";
 alert("回调函数2") ;
for(var name in date.cart){
string += "<tr><td style='border-bottom:1px solid #FFB31D;' width='35%'>"+date.cart[name].name+"</td>" 
   +"<td style='border-bottom:1px solid #FFB31D'><img src='images/logo/btn_minus.gif' alt=''></img>&nbsp;&nbsp;" 
   +"<input type='text' size='2' value="+date.cart[name].amount+" />&nbsp;&nbsp;<img src='images/logo/btn_add.gif' alt=''></img></td>"
   +"<td style='border-bottom:1px solid #FFB31D;' width='35%'>" +date.cart[name].subTotal+"</td>"
   + "<td style='border-bottom:1px solid #FFB31D' width='15%'><img src='images/logo/btn_close.gif' alt='取消'&g