json字符串传到前台input

JSONObject把对象转换成的json字符串,无法直接通过request.setAttribute();传到页面的input标签

如下是错误的:
request.setAttribute(“pageInfoJsonStr”, JSONObject.fromObject(pageInfo).toString());

还需要 jsonStr.replaceAll(“\”“, “’”)再放到request.setAttribute中
---------------------

JSONArray jsonList = new JSONArray();
if (TaskListReturn != null) {
jsonList = JSONArray.fromObject(TaskListReturn);
}
if (SuperviseManage != null) {
SuperviseManage.put("list", TaskList);
String obj = jsonList.toString();
obj = obj.replace("\"", "'");
SuperviseManage.put("jsonList", obj);
}
SuperviseManage.put("TaskcountReturn", TaskcountReturn);

猜你喜欢

转载自www.cnblogs.com/konglxblog/p/10078314.html