/**
   * 功能描述:全局异常处理
   *
   * @param user 用户对象
   * @return 视图
   */
  @RequestMapping(value = "/login")
  public String login(User user) {

    if (user == null || user.getName() == null) {
      return "UserRest/login";
    } else if (user.getName().equals("NICK")) {
      throw new UserException("用户名不正确!");
    }

    return "UserRest/login";
  }
  // 用户添加操作,POST访问方法
  // REST风格
  @RequestMapping(value = "/add", method = RequestMethod.POST)
  public String add(@Validated User user, BindingResult br, ModelMap modelMap)
      throws Exception { // BindingResult放置对象以后

    if (br.hasErrors()) {
      // 检验出现错误,返回添加页面
      return "UserRest/add";
    }

    if (userService.findOne(user.getId()) != null) {
      userService.update(user);
      // throw new Exception("sdfdsf");
    } else {
      userService.create(user);
    }

    return "redirect:/system/UserControllerRest/get";
  }