sp; request.setCharacterEncoding("UTF-8"); response.setContentType("text/json;charset=utf-8"); log.info("reach ChangeElectSet"); String json = (String) request.getParameter("json").trim(); log.info("Change ElectSet"); log.info(json); ElectSet sets = new ElectSet(); JSONObject jsonObject = JSONObject.fromObject(json); sets = (ElectSet) JSONObject.toBean(jsonObject, ElectSet.class); if(sets.getIsReadDB()=="false"){ sets.setIsReadDB("否"); } else{ sets.setIsReadDB("是"); } String changes="{"xuenian":"";//因为json的属性要用引号,所以要用"转义一下 changes =sets.getXuenian() "","xueqi":"" sets.getXueqi() "","startTime":"" sets.getStartTime() "","endTime":"" sets.getEndTime() "","menshu":"" sets.getMenshu() "","isReadDB":"" sets.getIsReadDB() ""}"; System.out.println(changes); String absPath = request.getRealPath(""); String filePath = absPath "publicsetselectSets.json";