コード例 #1
0
  @ResponseBody
  @RequestMapping(value = "/register", method = RequestMethod.GET)
  public Map<String, Object> register(/*Student s*/ ) {
    Map<String, Object> map = new HashMap<String, Object>();
    String tip = "添加成功";
    int error = 0;

    Student ss = new Student();
    ss.setName("dsun");
    ss.setAge(30);

    Profile pro = new Profile();
    pro.setHigh("1.78m");
    pro.setWeight("150kg");

    pro.setStudent(ss);
    ss.setProfile(pro);

    boolean b = us.saveStudent(ss);
    if (!b) {
      tip = "添加失败";
      error++;
    }

    map.put("tip", tip);
    map.put("error", error);

    return map;
  }
コード例 #2
0
  @ResponseBody
  @RequestMapping(
      value = "/pageList",
      method = {RequestMethod.POST, RequestMethod.GET})
  public Map<String, Object> pageList(
      @RequestParam(value = "page", required = true) int page,
      @RequestParam(value = "size", required = true) int size) {
    Map<String, Object> map = new HashMap<String, Object>();
    String tip = "查询成功";
    int error = 0;

    map.put("studentLisst", us.pageList(page, size));

    map.put("tip", tip);
    map.put("error", error);

    return map;
  }