I'm using Spring MVC and I'm wondering is it possible to change URL when I return ModelAndView (the view is situated at the WEB-INF folder, so redirecting to it is not working) from the controller? I mean when I return it the URL is the previous one, and its obvious because dispatcher is working, not the redirecting.
@RequestMapping(value = "/login", method = RequestMethod.POST)
public ModelAndView authenticate(@RequestParam("login") String login, @RequestParam("password") String password) {
ModelAndView modelAndView = new ModelAndView();
User user = userDao.getUserByLogin(login);
if (user != null && user.getPassword().equals(password)) {
modelAndView.addObject("user", user);
modelAndView.setViewName("home");
}
return modelAndView;
}
So my home
model is in WEB-INF folder, so return redirect:/home
will not work for it. Yes, I can redirect it with return home
, but in that case the URL will not change.