Ejemplo n.º 1
2
  private void get(HttpServletRequest request, HttpServletResponse response) throws IOException {
    PrintWriter out = response.getWriter();
    String sPage = request.getParameter("page");
    String sRows = request.getParameter("rows");
    String order = request.getParameter("order");
    String sort = request.getParameter("sort");
    int page = 0;
    int rows = 0;
    if (sPage != null && sRows != null) {
      page = Integer.parseInt(sPage);
      rows = Integer.parseInt(sRows);
    }

    int total = service.count();
    List list = service.get(page, rows, order, sort);
    Map m = new HashMap();
    m.put("total", total);
    m.put("rows", list);

    JSONArray jsonArray = new JSONArray().fromObject(m);
    String json = jsonArray.toString();
    String j = json.substring(1, json.lastIndexOf("]"));

    out.write(j);
  }
Ejemplo n.º 2
0
  // 修改学院信息
  private void edit(HttpServletRequest request, HttpServletResponse response) throws IOException {
    PrintWriter out = response.getWriter();
    JsonBean j = new JsonBean();
    int id = Integer.parseInt(request.getParameter("id"));
    int college_num = Integer.parseInt(request.getParameter("college_num"));
    int college_state = Integer.parseInt(request.getParameter("college_state"));
    String college_name = request.getParameter("college_name");

    College co = new College();
    co.setCollege_name(college_name);
    co.setCollege_num(college_num);
    co.setCollege_state(college_state);
    co.setId(id);

    if (service.edit(co)) {
      j.setSuccess(true);
      j.setMsg("修改[" + college_name + "]成功!");
    } else {
      j.setMsg("修改[" + college_name + "]失败!");
    }

    JSONArray jsonArray = new JSONArray().fromObject(j);
    String jsonS = jsonArray.toString();
    String json = jsonS.substring(1, jsonS.lastIndexOf("]"));
    out.write(json);
  }
Ejemplo n.º 3
0
  private void getName(HttpServletRequest request, HttpServletResponse response)
      throws IOException {
    PrintWriter out = response.getWriter();
    List list = service.get(0, 0, null, null);

    JSONArray jsonArray = new JSONArray().fromObject(list);
    String json = jsonArray.toString();

    out.write(json);
  }
Ejemplo n.º 4
0
  // 删除学院
  private void del(HttpServletRequest request, HttpServletResponse response) throws IOException {
    PrintWriter out = response.getWriter();
    JsonBean j = new JsonBean();
    String ids = request.getParameter("ids");

    service.del(ids);
    j.setSuccess(true);

    JSONArray jsonArray = new JSONArray().fromObject(j);
    String jsonS = jsonArray.toString();
    String json = jsonS.substring(1, jsonS.lastIndexOf("]"));
    out.write(json);
  }