コード例 #1
0
  @RequestMapping("my_view_articles")
  public ModelAndView getMyArticles(HttpSession session) {
    ModelAndView mv = new ModelAndView("my_view_articles");

    Integer userId = (Integer) session.getAttribute("userId");
    if (service.getMyArticles(userId) == null) {
      return mv;
    } else {
      mv.addObject("my_lst", service.getMyArticles(userId));
    }
    return mv;
  }
コード例 #2
0
  @RequestMapping("edit")
  public ModelAndView edit(
      @RequestParam("tit") String tit,
      @RequestParam("cont") String cont,
      @RequestParam("desc") String desc,
      @RequestParam("articleId") Integer articleId) {
    ModelAndView mv = new ModelAndView("my_view_articles");

    Article article = service.getArticle(articleId);
    article.setContent(cont);
    article.setTitle(tit);
    article.setDescription(desc);
    service.updateArticle(article);
    return mv;
  }
コード例 #3
0
  @RequestMapping("editform")
  public ModelAndView editform(@RequestParam("articleId") Integer articleId) {
    ModelAndView mv = new ModelAndView("editform");

    mv.addObject("article", service.getArticle(articleId));
    return mv;
  }
コード例 #4
0
  @RequestMapping("save")
  public ModelAndView save(
      @RequestParam("tit") String tit,
      @RequestParam("cont") String cont,
      @RequestParam("desc") String desc,
      HttpSession session) {
    ModelAndView mv = new ModelAndView("my_view_articles");

    Integer userId = (Integer) session.getAttribute("userId");

    User user = service.getUser(userId);
    log.log(Level.INFO, "User:", user.getName());
    Article article = new Article(tit, desc, cont, user);
    service.saveArticle(article);
    return mv;
  }
コード例 #5
0
  @RequestMapping("my_view_article")
  public ModelAndView getMyArticle(@RequestParam("id") Integer id) {
    ModelAndView mv = new ModelAndView("my_view_article");

    mv.addObject("article", service.getArticle(id));
    return mv;
  }