Package springblog.controller

Source Code of springblog.controller.CommentController

package springblog.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import springblog.manager.CommentManager;
import springblog.pojo.Comment;

@Controller
public class CommentController {
 
  @Autowired
  private CommentManager commentManager = null;
 
 
  @RequestMapping(value = {"/comment/{commentID}/delete"})
  public String deleteComment(@PathVariable int commentID, Model model) {
    Comment comment = commentManager.getCommentByID(commentID);
    if (null == comment) {
      model.addAttribute("message", "No such comment.");
      return "message";
    }
    commentManager.delete(comment);
    return "redirect:/article/" + comment.getArticleID();
  }
}
TOP

Related Classes of springblog.controller.CommentController

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.