@Test public void get() throws Exception { MvcResult mvcResult = mockMvc.perform(MockMvcRequestBuilders.get("/dict/3").accept(MediaType.APPLICATION_JSON)).andReturn(); int status = mvcResult.getResponse().getStatus(); String content = mvcResult.getResponse().getContentAsString(); System.out.println(status + "--" + content); }
@RequestMapping(value="/{id}") public ActionResultObj get(@PathVariable Long id){ ActionResultObj result = new ActionResultObj(); try{ if(id != 0){ EDict dict = dictDao.fetch(id); if(dict != null){ result.ok(dict); result.okMsg("查询成功！"); }else{ result.errorMsg("查询失败！"); } }else{ result.errorMsg("查询失败，链接不存在！"); } }catch(Exception e){ LOG.error("查询失败，原因："+e.getMessage()); result.error(e); } return result; }
DictController { @RequestMapping(value="/{id}") public ActionResultObj get(@PathVariable Long id){ ActionResultObj result = new ActionResultObj(); try{ if(id != 0){ EDict dict = dictDao.fetch(id); if(dict != null){ result.ok(dict); result.okMsg("查询成功！"); }else{ result.errorMsg("查询失败！"); } }else{ result.errorMsg("查询失败，链接不存在！"); } }catch(Exception e){ LOG.error("查询失败，原因："+e.getMessage()); result.error(e); } return result; } }
DictController { @RequestMapping(value="/{id}") public ActionResultObj get(@PathVariable Long id){ ActionResultObj result = new ActionResultObj(); try{ if(id != 0){ EDict dict = dictDao.fetch(id); if(dict != null){ result.ok(dict); result.okMsg("查询成功！"); }else{ result.errorMsg("查询失败！"); } }else{ result.errorMsg("查询失败，链接不存在！"); } }catch(Exception e){ LOG.error("查询失败，原因："+e.getMessage()); result.error(e); } return result; }  }
DictController { @RequestMapping(value="/{id}") public ActionResultObj get(@PathVariable Long id){ ActionResultObj result = new ActionResultObj(); try{ if(id != 0){ EDict dict = dictDao.fetch(id); if(dict != null){ result.ok(dict); 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="type/{type}") ActionResultObj findByType(@PathVariable String type); @RequestMapping(value="/{id}") ActionResultObj get(@PathVariable Long id); @RequestMapping(value="save") ActionResultObj save(@RequestBody EDict dict); @RequestMapping(value="delete") ActionResultObj delete(@RequestBody Long id); }
DictController { @RequestMapping(value="/{id}") public ActionResultObj get(@PathVariable Long id){ ActionResultObj result = new ActionResultObj(); try{ if(id != 0){ EDict dict = dictDao.fetch(id); if(dict != null){ result.ok(dict); 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="type/{type}") ActionResultObj findByType(@PathVariable String type); @RequestMapping(value="/{id}") ActionResultObj get(@PathVariable Long id); @RequestMapping(value="save") ActionResultObj save(@RequestBody EDict dict); @RequestMapping(value="delete") ActionResultObj delete(@RequestBody Long id); @Autowired
	public DictService dictService; @Autowired
	public DictDao dictDao; }