@Test public void get() throws Exception { MvcResult mvcResult = mockMvc.perform(MockMvcRequestBuilders.get("/org/3").accept(MediaType.APPLICATION_JSON)).andReturn(); int status = mvcResult.getResponse().getStatus(); String content = mvcResult.getResponse().getContentAsString(); System.out.println(status + "--" + content); }
@RequestMapping(value = "/get/{id}") public ActionResultObj get(@PathVariable Long id) { ActionResultObj result = new ActionResultObj(); try { if (id != 0) { EOrg org = orgDao.fetch(id); if (org != null) { WMap map = new WMap(); map.put("data", org); result.ok(map); result.okMsg("查询成功！"); } else { result.errorMsg("查询失败！"); } } else { result.errorMsg("查询失败，链接不存在！"); } } catch (Exception e) { LOG.error("查询失败，原因：" + e.getMessage()); result.error(e); } return result; }
OrgController { @RequestMapping(value = "/get/{id}") public ActionResultObj get(@PathVariable Long id) { ActionResultObj result = new ActionResultObj(); try { if (id != 0) { EOrg org = orgDao.fetch(id); if (org != null) { WMap map = new WMap(); map.put("data", org); result.ok(map); result.okMsg("查询成功！"); } else { result.errorMsg("查询失败！"); } } else { result.errorMsg("查询失败，链接不存在！"); } } catch (Exception e) { LOG.error("查询失败，原因：" + e.getMessage()); result.error(e); } return result; } }
OrgController { @RequestMapping(value = "/get/{id}") public ActionResultObj get(@PathVariable Long id) { ActionResultObj result = new ActionResultObj(); try { if (id != 0) { EOrg org = orgDao.fetch(id); if (org != null) { WMap map = new WMap(); map.put("data", org); result.ok(map); result.okMsg("查询成功！"); } else { result.errorMsg("查询失败！"); } } else { result.errorMsg("查询失败，链接不存在！"); } } catch (Exception e) { LOG.error("查询失败，原因：" + e.getMessage()); result.error(e); } return result; }  }
OrgController { @RequestMapping(value = "/get/{id}") public ActionResultObj get(@PathVariable Long id) { ActionResultObj result = new ActionResultObj(); try { if (id != 0) { EOrg org = orgDao.fetch(id); if (org != null) { WMap map = new WMap(); map.put("data", org); result.ok(map); result.okMsg("查询成功！"); } else { result.errorMsg("查询失败！"); } } else { result.errorMsg("查询失败，链接不存在！"); } } catch (Exception e) { LOG.error("查询失败，原因：" + e.getMessage()); result.error(e); } return result; }  @RequestMapping(value = "/list") ActionResultObj list(@RequestBody SearchQueryJS queryJs); @RequestMapping(value = "/get/{id}") ActionResultObj get(@PathVariable Long id); @RequestMapping(value = "/save") ActionResultObj save(@RequestBody EOrg org); @RequestMapping(value = "/delete/{id}") ActionResultObj delete(@PathVariable Long id); @RequestMapping(value = "/getOrgs/{type}") ActionResultObj getOrgsByListByType(@PathVariable String type); }
OrgController { @RequestMapping(value = "/get/{id}") public ActionResultObj get(@PathVariable Long id) { ActionResultObj result = new ActionResultObj(); try { if (id != 0) { EOrg org = orgDao.fetch(id); if (org != null) { WMap map = new WMap(); map.put("data", org); result.ok(map); result.okMsg("查询成功！"); } else { result.errorMsg("查询失败！"); } } else { result.errorMsg("查询失败，链接不存在！"); } } catch (Exception e) { LOG.error("查询失败，原因：" + e.getMessage()); result.error(e); } return result; }  @RequestMapping(value = "/list") ActionResultObj list(@RequestBody SearchQueryJS queryJs); @RequestMapping(value = "/get/{id}") ActionResultObj get(@PathVariable Long id); @RequestMapping(value = "/save") ActionResultObj save(@RequestBody EOrg org); @RequestMapping(value = "/delete/{id}") ActionResultObj delete(@PathVariable Long id); @RequestMapping(value = "/getOrgs/{type}") ActionResultObj getOrgsByListByType(@PathVariable String type); @Autowired
	public OrgService orgService; @Autowired
	public OrgDao orgDao; @Autowired
	public AreaDao areaDao; }