从URL取数据的方式
1.HttpServletRequest request 方式
public ResultVO login(HttpServletRequest request, HttpSession session){
String userName = request.getParameter("username");
String userPassword = request.getParameter("password");
}
2.UserForm userForm 传表单对象
public ResultVO register(@Valid UserForm userForm,
BindingResult bindingResult){
if(bindingResult.hasErrors()){
log.error("【用户注册】参数不正确,userForm={}",userForm);
throw new UserException(ResultEnum.PARAM_ERROR);
}
if(userService.checkValid(userForm.getUsername(),"username") == 1){
}
}
3.@RequestParam(“str”) String string 方式
public ResultVO checkValid(@RequestParam("str") String str, @RequestParam("type") String type){
Integer result = userService.checkValid(str, type);
if(result == 1){
log.error("【检查用户】用户已存在");
return ResultVOUtil.fail("用户已存在",null);
}else{
return ResultVOUtil.success("检验成功", null);
}
}