@Test public void get() throws Exception { MvcResult mvcResult = mockMvc.perform(MockMvcRequestBuilders.get("/area/delete/2").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) { EArea area = areaDao.fetch(id); if (area != null) { WMap map = new WMap(); map.put("data", area); result.ok(map); result.okMsg("查询成功！"); } else { result.errorMsg("查询失败！"); } } else { result.errorMsg("查询失败，链接不存在！"); } } catch (Exception e) { LOG.error("查询失败，原因：" + e.getMessage()); result.error(e); } return result; }
AreaController { @RequestMapping(value = "/get/{id}") public ActionResultObj get(@PathVariable Long id) { ActionResultObj result = new ActionResultObj(); try { if (id > 0) { EArea area = areaDao.fetch(id); if (area != null) { WMap map = new WMap(); map.put("data", area); result.ok(map); result.okMsg("查询成功！"); } else { result.errorMsg("查询失败！"); } } else { result.errorMsg("查询失败，链接不存在！"); } } catch (Exception e) { LOG.error("查询失败，原因：" + e.getMessage()); result.error(e); } return result; } }
AreaController { @RequestMapping(value = "/get/{id}") public ActionResultObj get(@PathVariable Long id) { ActionResultObj result = new ActionResultObj(); try { if (id > 0) { EArea area = areaDao.fetch(id); if (area != null) { WMap map = new WMap(); map.put("data", area); result.ok(map); result.okMsg("查询成功！"); } else { result.errorMsg("查询失败！"); } } else { result.errorMsg("查询失败，链接不存在！"); } } catch (Exception e) { LOG.error("查询失败，原因：" + e.getMessage()); result.error(e); } return result; }  }
AreaController { @RequestMapping(value = "/get/{id}") public ActionResultObj get(@PathVariable Long id) { ActionResultObj result = new ActionResultObj(); try { if (id > 0) { EArea area = areaDao.fetch(id); if (area != null) { WMap map = new WMap(); map.put("data", area); 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 = "/allArea", method = RequestMethod.POST) ActionResultObj findAllArea(@RequestBody SearchQueryJS queryJs); @RequestMapping(value = "/save") ActionResultObj save(@RequestBody EArea area); @RequestMapping(value = "/get/{id}") ActionResultObj get(@PathVariable Long id); @RequestMapping(value = "/delete/{id}") ActionResultObj delete(@PathVariable Long id); @RequestMapping(value = "/kunMingArea") ActionResultObj getKunMingArea(); }
AreaController { @RequestMapping(value = "/get/{id}") public ActionResultObj get(@PathVariable Long id) { ActionResultObj result = new ActionResultObj(); try { if (id > 0) { EArea area = areaDao.fetch(id); if (area != null) { WMap map = new WMap(); map.put("data", area); 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 = "/allArea", method = RequestMethod.POST) ActionResultObj findAllArea(@RequestBody SearchQueryJS queryJs); @RequestMapping(value = "/save") ActionResultObj save(@RequestBody EArea area); @RequestMapping(value = "/get/{id}") ActionResultObj get(@PathVariable Long id); @RequestMapping(value = "/delete/{id}") ActionResultObj delete(@PathVariable Long id); @RequestMapping(value = "/kunMingArea") ActionResultObj getKunMingArea(); @Autowired
	public AreaService areaService; @Autowired
	public AreaDao areaDao; }