每日总结
昨天考完六级,今天写了软件构造的作业,
public List<Tran> selecttres(String name) { String sql = "select * from translate where user = ?"; List<Tran> resultList = dao.find(sql, name); // 直接返回这个List return resultList; } public List<Picture> selecttres2(String name) { String sql = "select * from picture where user = ?"; List<Picture> resultList = dao2.find(sql, name); // 直接返回这个List return resultList; }
controller类:
public void resrcharts2() { String username = getPara("username"); String sss=""; //setAttr("res", adminService.selecttres(username)); List<Picture> jsonData = adminService.selecttres2(username); System.out.println(jsonData); ObjectMapper objectMapper = new ObjectMapper(); try { sss = objectMapper.writeValueAsString(jsonData); System.out.println(sss); } catch (JsonProcessingException e) { // 处理异常,例如记录日志或返回错误信息 e.printStackTrace(); } setAttr("res", sss); setAttr("username", username); render("res2.html"); } public void resrcharts1() { String username = getPara("username"); String sss=""; //setAttr("res", adminService.selecttres(username)); List<Tran> jsonData = adminService.selecttres(username); System.out.println(jsonData); ObjectMapper objectMapper = new ObjectMapper(); try { sss = objectMapper.writeValueAsString(jsonData); System.out.println(sss); } catch (JsonProcessingException e) { // 处理异常,例如记录日志或返回错误信息 e.printStackTrace(); } setAttr("res", sss); setAttr("username", username); render("res.html"); }