コード例 #1
0
  @RequestMapping(value = "", method = RequestMethod.POST)
  public ModelAndView saveTopic(Topic topic, HttpServletRequest request) {
    // User user = (User) request.getSession().getAttribute("LOGGEDIN_USER");

    User user = UserContextHolder.getMandatoryLoggedinUser(request.getSession());
    topic.setPostedOn(new Date());
    topic.setStartedBy(user);

    topic = this.forumService.createTopic(topic);
    long topicId = topic.getTopicId();
    String url = "/forums/" + topic.getForum().getForumId() + "/topics/" + topicId;
    ModelAndView mav = new ModelAndView("redirect:" + url);
    return mav;
  }
コード例 #2
0
  @RequestMapping(value = "", method = RequestMethod.GET, params = "newTopic")
  public ModelAndView newTopicForm(
      @PathVariable("forumId") long forumId, HttpServletRequest request) {
    UserContextHolder.getMandatoryLoggedinUser(request.getSession());

    ModelAndView mav = new ModelAndView("newTopic");
    Forum forum = new Forum();
    forum.setForumId(forumId);

    Topic topic = new Topic();
    topic.setForum(forum);

    mav.addObject("topic", topic);

    return mav;
  }