Announcement Announcement Module
No announcement yet.
Invoking another rest method after persisting data Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Invoking another rest method after persisting data

    Hi guys,
    I was wondering if it's possible to call "user/list" after adding user in the method addUser()!?

    Basically, what I'd like to do is to redirect the current page to the 'list' page after saving the 'user' to show the users fetched in the method list().

    public class RegisterController {
        @RequestMapping(method = RequestMethod.POST)
        public String addUser(){
            // adding user...
            return "user/list";
        @RequestMapping(value="user/list", method = RequestMethod.GET)
    	private ModelAndView list(Model model){
    		Collection<User> list = userService.findAll();
    		model.addAttribute("listUser", list);
    		return new ModelAndView("user/list");
    Doing by this way above, the page is redirected to the 'list' page but no data is showed due to the method list() not being called.
    Lemme know if I wasn't clear enough

    Ps.: I dont wanna invoke the list() method from addUser() through a direct call.
    If access http://localhost/.../user/list the method is invoked and the list is showed as expected.