/** 获取用户Details信息的回调函数. */
  public UserDetails loadUserByUsername(String userName)
      throws UsernameNotFoundException, DataAccessException {

    User user = userManager.findUserByLoginName(userName);
    if (user == null) {
      throw new UsernameNotFoundException("用户" + userName + " 不存在");
    }
    boolean enabled = true;
    if (user.getStatus() == 0) {
      enabled = false;
      throw new UsernameNotFoundException("用户" + userName + " 未激活");
    }
    GrantedAuthority[] grantedAuths = obtainGrantedAuthorities(user);

    boolean accountNonExpired = true;
    boolean credentialsNonExpired = true;
    boolean accountNonLocked = true;

    org.springframework.security.userdetails.User userdetail =
        new org.springframework.security.userdetails.User(
            user.getEmail(),
            user.getPassword(),
            enabled,
            accountNonExpired,
            credentialsNonExpired,
            accountNonLocked,
            grantedAuths);

    return userdetail;
  }
 /**
  * 进入登陆页面控制器
  *
  * @return 视图名字为register的资源。见view.properties
  * @throws ServletRequestBindingException ServletRequestBindingException异常
  */
 @RequestMapping(value = "/user/register.do", method = RequestMethod.POST)
 public String postRegisterUser(
     @ModelAttribute("user") User user,
     BindingResult result,
     HttpServletRequest request,
     HttpServletResponse response) {
   if (log.isDebugEnabled()) {
     log.debug("entering 'postRegisterUser' method...");
   }
   userManager.save(user);
   return "user/register";
 }