Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package cs544.blog.controller; import cs544.blog.entities.User; import cs544.blog.service.IBlogService; import javax.annotation.Resource; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; /** * * @author ajay */ //@Controller public class UserController { @Resource private IBlogService userService; // @RequestMapping("/") // public String redirectRoot(){ // return "redirect:/users"; // } @RequestMapping(value = "/users", method = RequestMethod.GET) public String getAll(Model model) { model.addAttribute("users", userService.getAllUser()); System.err.println(userService.getAllUser()); return "userList"; } @RequestMapping(value = "/registerUser", method = RequestMethod.GET) public String registerUser(ModelMap model) { model.addAttribute("user", new User()); return "registrationPage"; } // @RequestMapping(value="/users/{id}", method=RequestMethod.GET) // public String get(@PathVariable int id, Model model) { // model.addAttribute("users", userService.loadUser(id)); // return "userDetail"; // } // @RequestMapping(value="/users", method=RequestMethod.POST) // public String add(UserController user) { // userService.createUser(); // return "redirect:/cars"; // } // // @RequestMapping(value = "/user", method=RequestMethod.GET) // public String loadUser(Model model){ // model.addAttribute("users", userService.getAllUser()); // return "user"; // } }