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 > 0>
<#list refundChannels as refundChannel>
refundChannels[${refundChannel_index}]="${(refundChannel.title)!''}";
</#list>
</#if>
<#if refundConditions?exists && refundConditions?size > 0>
<#list refundConditions as refundCondition>
refundConditions[${refundCondition_index}]="${(refundCondition.title)!''}";
</#list>
</#if>
<#if refundCosts?exists && refundCosts?size > 0>
<#list refundCosts as refundCost>
refundCosts[${refundCost_index}]="${(refundCost.title)!''}";
</#list>
</#if>
<#if refundReceipts?exists && refundReceipts?size > 0>
<#list refundReceipts as refundReceipt>
refundReceipts[${refundReceipt_index}]="${(refundReceipt.title)!''}";
</#list>
</#if>
<#if refundRegions?exists && refundRegions?size > 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> ${(bankName)!''}</p>
<form id="saveForm" method="post">
<input type="hidden" name="deleteIds" id="deleteIds" value="">
信用卡网上还款>> <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 > 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>
信用卡网点还款>> <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 > 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>
信用卡外币还款>> <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 > 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>
信用卡其他还款>> <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 > 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()">
<input type="button" value="返回" οnclick="javascript:history.go(-1)">
</form>
</body>
</html>