json字符串转换为对象
JSONObject jo =JSONObject.fromObject(sysNumberRuleJsonStr);//这一步报错(运行时):The constructor JSONObject(String) is undefined
应改为:
JSONObject jo = new JSONObject();
JSONObject jsonObject = jo.fromObject(sysNumberRuleJsonStr);
SysNumberRule rule = (SysNumberRule) JSONObject.toBean(jo, SysNumberRule.class);
request.setAttribute("sysNumberRule", rule);
json字符串转换为list
String sysNumberRuleRows = request.getParameter("sysNumberRuleRows");
List<SysNumberRule> list = new ArrayList<SysNumberRule>();
JSONArray json = JSONArray.fromObject(sysNumberRuleRows);
rowslist = JSONArray.toList(json, SysNumberRule.class);
or
rowslist = JSONArray.toCollection(json, SysNumberRule.class);