@Test public void testUserRegister() throws Exception { String response = mockMvc.perform( get("/user/register") .contentType(MediaType.APPLICATION_FORM_URLENCODED) .param("name", "jack") .param("password", "12323") .param("phone", "189000000") .param("gender", "male") .param("nickName", "mack") ).andExpect(status().isOk()) .andDo(print()) .andReturn().getResponse().getContentAsString(); System.out.println("返回数据 = " + response); }
@RequestMapping("register") public String userRegister(@Validated UserRegisterParam param) throws Exception { User user = new User(); BeanUtils.copyProperties(user,param); if(userService.userRegister(user)) { return "注册成功"; } return "注册失败"; }
UserController { @RequestMapping("register") public String userRegister(@Validated UserRegisterParam param) throws Exception { User user = new User(); BeanUtils.copyProperties(user,param); if(userService.userRegister(user)) { return "注册成功"; } return "注册失败"; } }
UserController { @RequestMapping("register") public String userRegister(@Validated UserRegisterParam param) throws Exception { User user = new User(); BeanUtils.copyProperties(user,param); if(userService.userRegister(user)) { return "注册成功"; } return "注册失败"; }  }
UserController { @RequestMapping("register") public String userRegister(@Validated UserRegisterParam param) throws Exception { User user = new User(); BeanUtils.copyProperties(user,param); if(userService.userRegister(user)) { return "注册成功"; } return "注册失败"; }  @RequestMapping("register") String userRegister(@Validated UserRegisterParam param); @RequestMapping("getAllUser") List<User> getAllUserInfo(); }
UserController { @RequestMapping("register") public String userRegister(@Validated UserRegisterParam param) throws Exception { User user = new User(); BeanUtils.copyProperties(user,param); if(userService.userRegister(user)) { return "注册成功"; } return "注册失败"; }  @RequestMapping("register") String userRegister(@Validated UserRegisterParam param); @RequestMapping("getAllUser") List<User> getAllUserInfo();  }