W3Cschool
恭喜您成為首批注冊(cè)用戶
獲得88經(jīng)驗(yàn)值獎(jiǎng)勵(lì)
前臺(tái)web代碼
function update_save(frId){ debugger; var json={};//json對(duì)象里面的key完全包含于封裝的Bridge對(duì)象的屬性 $.each($('#'+frId).serializeArray(),function(index,item){ var brigeKey = this['name'] if(brigeKey.substring(0,4) == 'unst') return true; json[this['name']]=this['value']; }) var bridge = JSON.stringify(json); $.ajax({ url : 'bridge_modify.fdo', type : "POST", data :{"brgeJStr":bridge}, dataType : 'json', success : function(returndate, status) { debugger; dateObj = eval('(' + returndate + ')'); var flag = dateObj.flag; var msg = dateObj.msg; alert('modifyPan',' 修改數(shù)據(jù)',msg); }
});
}
java代碼
2.1 java的Bridge 模版
/*
橋梁對(duì)象 */ public class TBridge { private Long bridgeid;//主鍵
private String unst_fieldid;//查詢排序 private String unst_geoxy;//空間坐標(biāo)
private String deptkey;//管理單位代碼 private String departmentkeys;//管理單位代碼 //............省略get,set方法 }
2.2 java的對(duì)應(yīng)的Action 模版
public class TBridgeAction extends BaseActon implements Preparable{
private static final long serialVersionUID = 8309913025508352320L; private static Logger log = Logger.getLogger(TBridgeAction.class);
private String brgeJStr;
public String getBrgeJStr() { return brgeJStr;
} public void setBrgeJStr(String brgeJStr) {
this.brgeJStr = brgeJStr;
}
public String modify() throws Exception{
JSONObject jo = new JSONObject(); try{ //把前天傳過來的json字符串對(duì)象轉(zhuǎn)化成json對(duì)象 JSONObject jsonObject=JSONObject.fromObject(brgeJStr); //把前天傳過來的json字符串對(duì)象轉(zhuǎn)化成json對(duì)象后,再轉(zhuǎn)化為java封裝對(duì)象 TBridge bridge=(TBridge)JSONObject.toBean(jsonObject, TBridge.class); }catch(Exception e){ log.error("修改橋梁信息出錯(cuò),錯(cuò)誤信息:"+e.getMessage()); } return "success";
} }
Copyright©2021 w3cschool編程獅|閩ICP備15016281號(hào)-3|閩公網(wǎng)安備35020302033924號(hào)
違法和不良信息舉報(bào)電話:173-0602-2364|舉報(bào)郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號(hào)
聯(lián)系方式:
更多建議: