Package net.baguajie.web.mvc.controllers

Source Code of net.baguajie.web.mvc.controllers.ViewSingleCommentController

package net.baguajie.web.mvc.controllers;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import net.baguajie.domains.Comment;
import net.baguajie.exceptions.ResourceNotFoundException;
import net.baguajie.repositories.CommentRepository;
import net.baguajie.web.utils.AjaxUtil;

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 org.springframework.web.bind.annotation.RequestMethod;

@Controller
@RequestMapping("/ops")
public class ViewSingleCommentController {

  @Autowired
  CommentRepository commentRepository;
  @Autowired
  private AjaxUtil ajaxUtil;
 
  @RequestMapping(value="/cmt/{id}/view/{type}", method=RequestMethod.GET)
  public String view(@PathVariable String id,
      @PathVariable String type, Model model,
      HttpServletRequest request, HttpSession session){
    if(!ajaxUtil.isAjaxRequest(request)){
      throw new ResourceNotFoundException();
    }
    Comment cmt = commentRepository.findOne(id);
    model.addAttribute("cmt", cmt);
    return "ops/cmt."+ type;
  }
 
}
TOP

Related Classes of net.baguajie.web.mvc.controllers.ViewSingleCommentController

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.