//前台
jQuery.ajax({
method: 'post',
url: "${path}/xxx.do?m=xxx",
dataType: 'json',
success: function(data){
}
});
//后台
try {
JSONArray projectArray = new JSONArray();
for (ProjectExt pe : projectExtList) {
JSONObject peObj = new JSONObject();
peObj.put("id", pe.getId());
peObj.put("name", pe.getName());
peObj.put("startTime", sdf.format( pe.getStarttime() ));
peObj.put("endTime", sdf.format( pe.getEndtime() ));
peObj.put("usedHours", pe.getUsedHours()==null?0:pe.getUsedHours());
peObj.put("projectSn", String.valueOf( pe.getSn()==null?0:pe.getSn() ));
projectArray.put( peObj );
}
resultString = projectArray.toString();
HttpServletResponse response = ServletActionContext.getResponse();
response.setCharacterEncoding("UTF-8");
PrintWriter writer = response.getWriter();
writer.write(resultString);
} catch (Exception e) {
e.printStackTrace();
}