コード例 #1
0
 @RequestMapping(value = "/postdetails", method = RequestMethod.GET)
 public String postDetails(
     Model model, @RequestParam("post_id") Long postId, HttpServletRequest request) {
   Post currentPost = postsService.getPost(postId);
   model.addAttribute("post", currentPost);
   model.addAttribute("author", usersService.getUser(currentPost.getAuthor().getId()));
   return "textview";
 }
コード例 #2
0
  @RequestMapping(value = "/signup", method = RequestMethod.POST)
  public String register(
      @RequestParam("email_submiting") String email,
      @RequestParam("password_submiting") String pass,
      HttpServletRequest request) {
    usersService.register(email, pass);

    return "redirect:/";
  }
コード例 #3
0
  @RequestMapping(value = "/userprofile", method = RequestMethod.GET)
  public String userProfile(
      Model model, @RequestParam(value = "user_id", defaultValue = "") String userId) {
    Long id = 0L;
    boolean parsingSucces = true;
    if (userId.length() > 0) {
      try {
        id = Long.parseLong(userId);
        if (usersService.getUser(id) == null) id = User.getCurrentUser().getId();
      } catch (NumberFormatException numFormatException) {
        parsingSucces = false;
      }
    }
    if (!parsingSucces || userId.length() == 0) id = User.getCurrentUser().getId();

    model.addAttribute("user", usersService.getUser(id));
    model.addAttribute("current_user_id", User.getCurrentUser().getId());
    return "user_profile";
  }
コード例 #4
0
 @RequestMapping(value = "/storeuserinfo", method = RequestMethod.POST)
 public String storeUserInfo(
     HttpServletRequest request,
     @RequestParam(value = "address", defaultValue = "") String address,
     @RequestParam(value = "phone", defaultValue = "") String phone,
     @RequestParam(value = "fullName", defaultValue = "") String fullName,
     @RequestParam(value = "gender", defaultValue = "") Gender gender) {
   User u = User.getCurrentUser();
   u.setAddress(address);
   u.setPhone(phone);
   u.setFullName(fullName);
   u.setGender(gender);
   usersService.updateUserInfo(u);
   String referer = request.getHeader("Referer");
   return "redirect:" + referer;
 }