When I execute for example deleteUser using the link ... / deleteUser / name

then return to "/ main". But it returns all the same on: / deleteUser

@RequestMapping(value = "/deleteUser", method = RequestMethod.POST) @ResponseBody public ModelAndView createAlbum(@RequestParam("name") String name) throws Exception { ... ModelAndView model = new ModelAndView("/main"); return model; } 

I can’t do anything to redirect to / main page after this request

    1 answer 1

    Try using return "redirect:/любой/путь"; . True, you have to remove the @ResponseBody annotation.

      @RequestMapping(value = "/deleteUser", method = RequestMethod.POST) public String createAlbum(@RequestParam("name") String name) throws Exception { ... ModelAndView model = new ModelAndView("/main"); ... return "redirect:/любой/путь"; } 
    • one
      Thank you dear man. I could not understand the scratch for a long time redirect does not work. It turned out the case in the annotations - Loligan