Example #1
0
 @RequestMapping("/updatearticle")
 public String updateArticle(HttpServletRequest request) {
   String articleid = request.getParameter("articleid");
   String title = request.getParameter("title");
   String content = request.getParameter("content");
   Article article = articleManager.getById(Long.valueOf(articleid).longValue());
   article.setTitle(title);
   article.setContent(content);
   articleManager.update(article);
   request.setAttribute("ARTICLE", article);
   return "backend/article/update";
 }
Example #2
0
 @RequestMapping("/addcomment")
 public String addComment(HttpServletRequest request) {
   String articleid = request.getParameter("articleid");
   String content = request.getParameter("comment");
   Article article = articleManager.getById(Long.valueOf(articleid).longValue());
   List comments = article.getComments();
   if (comments == null) {
     comments = new ArrayList();
   }
   Comment comment = new Comment(content);
   comment.setArticle(article);
   comment.setCommentDate(new Date());
   comments.add(comment);
   articleManager.save(article);
   request.setAttribute("ARTICLE", article);
   return "frontend/showarticle";
 }