springmvc传递list对象

   

controller中是这样写的   写一个包装类

@SuppressWarnings("all")

    @RequestMapping("save")
    public String save(@RequestParam(value = "deleteIds") String deleteIds,
            @ModelAttribute("refundListWrapper") RefundListWrapper refundListWrapper,Model model) {
        ExecuteResult eresult = new ExecuteResult();
        try {
            List<CreditcardRefund> newCreditcardRefunds = new ArrayList<CreditcardRefund>();
            List<CreditcardRefund> creditcardRefunds = refundListWrapper.getNewRefundList();
            for (CreditcardRefund creditcardRefund : creditcardRefunds) {
                creditcardRefund.setCreator(getUser().getRealName());
                newCreditcardRefunds.add(creditcardRefund);
            }
            Result result = creditcardRefundService.save(deleteIds, newCreditcardRefunds);
            resultToModel(model, result);
            String msg = result.getResultCode().getMessage();
            if (result.isSuccess()) {
                eresult.setSuccess(true);
                addLog(getUser().getRealName() + "-修改信用卡还款异常-id:");
            }
            eresult.setMessage(msg);
        } catch (Exception e) {
            eresult.setMessage("新增异常");
            eresult.setException(e);
            LOG.error("修改信用卡还款异常", e);
        }
        eresult.setRedirectUrl(getReturnUrl());
        model.addAttribute("result", eresult);
        return SHOW_MSG_PAGE;
    }

    public static class RefundListWrapper implements Serializable{
        private static final long serialVersionUID = -5106497046336367248L;

        private List<CreditcardRefund> newRefundList;

        public List<CreditcardRefund> getNewRefundList() {
            return newRefundList;
        }

        public void setNewRefundList(List<CreditcardRefund> newRefundList) {
            this.newRefundList = newRefundList;
        }

    }



页面是这样写的  这个页面很有难度 慢慢看把


<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <link href="${contextPath}/resource/css/base.css" rel="stylesheet" type="text/css" />

    <script type="text/javascript" src="${back.jsPath}/jquery-1.3.2.min.js"></script>
    <script language="javascript" src="${back.jsPath}/jquery-1.3.2.min.js"></script>
</head>
<script type="text/javascript">
    var refundChannels = new Array();
    var refundConditions = new Array();
    var refundCosts = new Array();
    var refundReceipts = new Array();
    var refundRegions = new Array();
    $(function(){
        <#if refundChannels?exists && refundChannels?size &gt; 0>
         <#list refundChannels as refundChannel>
             refundChannels[${refundChannel_index}]="${(refundChannel.title)!''}";
         </#list>
        </#if>
        <#if refundConditions?exists && refundConditions?size &gt; 0>
         <#list refundConditions as refundCondition>
             refundConditions[${refundCondition_index}]="${(refundCondition.title)!''}";
        </#list>
        </#if>
        <#if refundCosts?exists && refundCosts?size &gt; 0>
         <#list refundCosts as refundCost>
             refundCosts[${refundCost_index}]="${(refundCost.title)!''}";
         </#list>
        </#if>
        <#if refundReceipts?exists && refundReceipts?size &gt; 0>
         <#list refundReceipts as refundReceipt>
             refundReceipts[${refundReceipt_index}]="${(refundReceipt.title)!''}";
         </#list>
        </#if>
        <#if refundRegions?exists && refundRegions?size &gt; 0>
         <#list refundRegions as refundRegion>
             refundRegions[${refundRegion_index}]="${(refundRegion.title)!''}";
         </#list>
        </#if>
    })
    
    function deleteRefund(id){
        if(window.confirm("确认删除该项吗?保存后有效")){
            var deleteIds = $('#deleteIds').val();
            deleteIds = deleteIds + id + ",";
            $('#deleteIds').val(deleteIds);
            $('#refund-'+id).remove();
        }        
    }
    var count = 0;
    function newRefund(type){
        count++;
        var add =    '<tr bgcolor="#FFFFFF" align="center" id="newRefund-'+count+'">'+
                    '<td width="18%">'+getRefundChannels(count)+'</td>'+
                    '<td width="18%">'+getRefundConditions(count)+'</td>'+
                    '<td width="18%">'+getRefundRegions(count)+'</td>'+
                    '<td width="18%">'+getRefundCosts(count)+'</td>'+
                    '<td width="18%">'+getRefundReceipts(count)+'</td>'+
                    '<td width="10%"><a href="javascript:deleteNew('+count+')">删除</td></tr>'+

                    '<input type="hidden" name="newRefundList['+(count-1)+'].bankId" value="${bankId!''}">'+
                    '<input type="hidden" name="newRefundList['+(count-1)+'].refundType" value="'+type+'">';
                    '<input type="hidden" name="newRefundList['+(count-1)+'].bankId" value="${bankId}">'+
                    '<input type="hidden" name="newRefundList['+(count-1)+'].refundType" value="'+type+'">';
                    
        $('#refundType-'+type).append(add);            
    }
    function deleteNew(count){
        $('#newRefund-'+count).remove();
        count--;
    }
    
    function getRefundChannels(count){
        var select = '<select name="newRefundList['+(count-1)+'].refundChannel">';
        for(i=0;i<refundChannels.length;i++){
            var content = refundChannels[i];
            select += '<option value='+content+'>'+content+'</option>';
        }
        return select;
    }
    function getRefundConditions(count){
        var select = '<select name="newRefundList['+(count-1)+'].refundConditions">';
        for(i=0;i<refundConditions.length;i++){
            var content = refundConditions[i];
            select += '<option value='+content+'>'+content+'</option>';
        }
        return select;
    }
    function getRefundRegions(count){
        var select = '<select name="newRefundList['+(count-1)+'].refundArea">';
        for(i=0;i<refundRegions.length;i++){
            var content = refundRegions[i];
            select += '<option value='+content+'>'+content+'</option>';
        }
        return select;
    }
    function getRefundCosts(count){
        var select = '<select name="newRefundList['+(count-1)+'].refundCost">';
        for(i=0;i<refundCosts.length;i++){
            var content = refundCosts[i];
            select += '<option value='+content+'>'+content+'</option>';
        }
        return select;
    }
    function getRefundReceipts(count){
        var select = '<select name="newRefundList['+(count-1)+'].refundReceipt">';
        for(i=0;i<refundReceipts.length;i++){
            var content = refundReceipts[i];
            select += '<option value='+content+'>'+content+'</option>';
        }
        return select;
    }    
    function formSubmit(){
        $('#saveForm').attr("action","${contextPath}/back/credit/credit/refund/save.htm");
        $('#saveForm').submit();
    }
</script>
<body>
    <p><IMG height=14 src="${back.imagePath}/book1.gif" width=20>&nbsp;&nbsp;${(bankName)!''}</p>
     <form id="saveForm" method="post">
     <input type="hidden" name="deleteIds" id="deleteIds" value="">
        &nbsp;&nbsp;信用卡网上还款>>&nbsp;&nbsp;<input type="button" οnclick="newRefund(1)" value="新增">
        <table border="0" width="80%" cellpadding="2" cellspacing="1" bgcolor="#D1DDAA" id="refundType-1">
            <tr width="100%" bgcolor="#FDFEE9" align="center" >
                <td width="18%">还款渠道</td>
                <td width="18%">适用条件</td>
                <td width="18%">适用区域</td>
                <td width="18%">手续费</td>
                <td width="18%">入账时间</td>
                <td width="10">操作</td>
            </tr>
            <#if creditcardRefunds?exists && creditcardRefunds?size &gt; 0>
                <#list creditcardRefunds as refund>
                    <#if refund.refundType==1>
                    <tr bgcolor="#FFFFFF" align="center" id="refund-${(refund.id)!''}"
                        οnmοusemοve="javascript:this.bgColor='#EDF7D0';" οnmοuseοut="javascript:this.bgColor='#FFFFFF';">
                        <td width="18%">${(refund.refundChannel)!''}</td>
                        <td width="18%">${(refund.refundConditions)!''}</td>
                        <td width="18%">${(refund.refundArea)!''}</td>
                        <td width="18%">${(refund.refundCost)!''}</td>
                        <td width="18%">${(refund.refundReceipt)!''}</td>
                        <td width="10%">
                            <a href="javascript:deleteRefund(${(refund.id)!''})">删除</a>
                        </td>
                    </tr>
                    </#if>
                </#list>
            </#if>            
        </table>
        <p>
        &nbsp;&nbsp;信用卡网点还款>>&nbsp;&nbsp;<input type="button" οnclick="newRefund(2)" value="新增">
        <table border="0" width="80%" cellpadding="2" cellspacing="1" bgcolor="#D1DDAA" id="refundType-2">
            <tr width="100%" bgcolor="#FDFEE9" align="center" >
                <td width="18%">还款渠道</td>
                <td width="18%">适用条件</td>
                <td width="18%">适用区域</td>
                <td width="18%">手续费</td>
                <td width="18%">入账时间</td>
                <td width="10">操作</td>
            </tr>
            <#if creditcardRefunds?exists && creditcardRefunds?size &gt; 0>
                <#list creditcardRefunds as refund>
                    <#if refund.refundType==2>
                    <tr bgcolor="#FFFFFF" align="center" id="refund-${(refund.id)!''}"
                        οnmοusemοve="javascript:this.bgColor='#EDF7D0';" οnmοuseοut="javascript:this.bgColor='#FFFFFF';">
                        <td width="18%">${(refund.refundChannel)!''}</td>
                        <td width="18%">${(refund.refundConditions)!''}</td>
                        <td width="18%">${(refund.refundArea)!''}</td>
                        <td width="18%">${(refund.refundCost)!''}</td>
                        <td width="18%">${(refund.refundReceipt)!''}</td>
                        <td width="10%">
                            <a href="javascript:deleteRefund(${(refund.id)!''})">删除</a>
                        </td>
                    </tr>
                    </#if>
                </#list>
            </#if>            
        </table>        
        <p>
        &nbsp;&nbsp;信用卡外币还款>>&nbsp;&nbsp;<input type="button" οnclick="newRefund(4)" value="新增">
        <table border="0" width="80%" cellpadding="2" cellspacing="1" bgcolor="#D1DDAA" id="refundType-4">
            <tr width="100%" bgcolor="#FDFEE9" align="center" >
                <td width="18%">还款渠道</td>
                <td width="18%">适用条件</td>
                <td width="18%">适用区域</td>
                <td width="18%">手续费</td>
                <td width="18%">入账时间</td>
                <td width="10">操作</td>
            </tr>
            <#if creditcardRefunds?exists && creditcardRefunds?size &gt; 0>
                <#list creditcardRefunds as refund>
                    <#if refund.refundType==4>
                    <tr bgcolor="#FFFFFF" align="center" id="refund-${(refund.id)!''}"
                        οnmοusemοve="javascript:this.bgColor='#EDF7D0';" οnmοuseοut="javascript:this.bgColor='#FFFFFF';">
                        <td width="18%">${(refund.refundChannel)!''}</td>
                        <td width="18%">${(refund.refundConditions)!''}</td>
                        <td width="18%">${(refund.refundArea)!''}</td>
                        <td width="18%">${(refund.refundCost)!''}</td>
                        <td width="18%">${(refund.refundReceipt)!''}</td>
                        <td width="10%">
                            <a href="javascript:deleteRefund(${(refund.id)!''})">删除</a>
                        </td>
                    </tr>
                    </#if>
                </#list>
            </#if>            
        </table>
        <p>
        &nbsp;&nbsp;信用卡其他还款>>&nbsp;&nbsp;<input type="button" οnclick="newRefund(3)" value="新增">
        <table border="0" width="80%" cellpadding="2" cellspacing="1" bgcolor="#D1DDAA" id="refundType-3">
            <tr width="100%" bgcolor="#FDFEE9" align="center" >
                <td width="18%">还款渠道</td>
                <td width="18%">适用条件</td>
                <td width="18%">适用区域</td>
                <td width="18%">手续费</td>
                <td width="18%">入账时间</td>
                <td width="10">操作</td>
            </tr>
            <#if creditcardRefunds?exists && creditcardRefunds?size &gt; 0>
                <#list creditcardRefunds as refund>
                    <#if refund.refundType==3>
                    <tr bgcolor="#FFFFFF" align="center" id="refund-${(refund.id)!''}"
                        οnmοusemοve="javascript:this.bgColor='#EDF7D0';" οnmοuseοut="javascript:this.bgColor='#FFFFFF';">
                        <td width="18%">${(refund.refundChannel)!''}</td>
                        <td width="18%">${(refund.refundConditions)!''}</td>
                        <td width="18%">${(refund.refundArea)!''}</td>
                        <td width="18%">${(refund.refundCost)!''}</td>
                        <td width="18%">${(refund.refundReceipt)!''}</td>
                        <td width="10%">
                            <a href="javascript:deleteRefund(${(refund.id)!''})">删除</a>
                        </td>
                    </tr>
                    </#if>
                </#list>
            </#if>            
        </table>
        <p>
        <input type="button" value="保存" οnclick="formSubmit()">&nbsp;&nbsp;&nbsp;&nbsp;
        <input type="button" value="返回" οnclick="javascript:history.go(-1)">
    </form>
</body>
</html>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值