$("#savename").click(function(){
var fananname=$("#editname").val();
var jsonList = eval(createArray());
var jsonText = JSON.stringify(jsonList);
$.ajax({
type: "POST",
url: "/shop/ffselect!saveAttachedUrl.action",
dataType:"json",
data: {
"fanan":fananname,
"jsonarray":jsonText
},
success: function(data) {
if(data.status=="success"){
window.location.href="www.baidu.com";
}
},
}); }) function createArray(){
var jsonarray=[];
var fanganid=$("#selectTitleid").val();
var $goodsurl=$(".goodsurl");
var $isadd=$(".isadd");
var $review=$(".inputtextarea");
var $isclear=$(".isclear"); $.each($goodsurl,function(n){
var goodsurl=$($goodsurl[n]).val();
var isadd=$($isadd[n]).val();
var review=$($review[n]).val();
var isclear=$($isclear[n]).val();
var obj=createObj(goodsurl,isadd,fanganid,review,isclear);
jsonarray.push(obj);
})
return jsonarray;
} function createObj(urlval,isaddval,faidval,reviewval,isclearval){
return {
url:urlval,
isadd:isaddval,
faid:faidval,
review:reviewval,
isclear:isclearval
}
}

  后台接收

 public String saveAttachedUrl(){
LlSelectAttachedUrl attacheURL = new LlSelectAttachedUrl();
String fanan = getParameter("fanan");
String jsonarray = getParameter("jsonarray");
System.out.println(fanan);
System.out.println(jsonarray);
// String str = "[{'name':'张三','sex':'男'},{'name':'李四','sex':'女'},{'name':'王五','sex':'男'}]";
JSONArray json = JSONArray.fromObject(jsonarray);
int size = json.size();
for(int i = 0; i<size; i++){
String re = json.getString(i);
JSONObject s = JSONObject.fromObject(re);
attacheURL.setAdd_date(new Date());
attacheURL.setComments(s.getString(""));
attacheURL.setGoods_url(s.getString(""));
attacheURL.setId(re);
attacheURL.setRemark(s.getString(""));
attacheURL.setSelect_title_id(s.getString(""));
if(s.getString("")!=null){
attacheURL.setIsAddUrl(Integer.parseInt(s.getString("")));
}if(s.getString("")!=null){
attacheURL.setState(Integer.parseInt(s.getString("")));
}
this.selectFanFan.saveSelectAttachedUrl(attacheURL);
}
return ajax(Status.success);
}

  

05-06 12:49