The foreground is converted to JSON format to pass multiple values, and the background gets the passed JSON format conversion

Frontend
var arr=[];//Save object to array
var json = {};//Object
json.je = aval;
json.type = type;
json.name = $("#name").combobox("getText ");
json.emp_code = $("#emp_code").val();
json.year_month = year_month;
arr.push(json);

var JSON = JSON.stringify(arr)
;//Convert the array to String type Pass JSON to the backend The


backend
receives the value passed by the String type
JSONArray.fromObject(json); convert to JSON format The


backend accepts json data and replaces the data with JSON list --- [color=darkred]JSONArray.fromObject(json); [ /color]
//dao insert data
public void addSalary(JSONArray array) throws SQLException {
StringBuffer sql = new StringBuffer();
sql.append("INSERT INTO TB_EMP_SALARY (ID, EMP_ORDEPR_ID, SALARY_TYPE_ID, JE, TYPE, YEAR_MONTH, NAME, EMP_CODE) ");
sql.append("VALUES (SEQ_TB_EMP_SALARY.NEXTVAL, #[emp_ordepr_id], #[salary_type_id], #[je], #[type], #[year_month], #[name], #[emp_code]) ");
SQLExecutor.insertBeans(sql.toString(), array);
}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326138775&siteId=291194637