A forma de retorno ModelAndView
@RequestMapping(value = "/list", method = RequestMethod.GET)
public ModelAndView list(
@UserAuth UserAuth user,
ModelAndView mav) {
if (!user.isAuthenticated()) {
mav.setViewName("redirect:http://www.test.com/login.jsp");
return mav;
}
mav.setViewName("list");
mav.addObject("articles", listService.getLists());
return mav;
}
A maneira de retornar String
@RequestMapping(value = "/list", method = RequestMethod.GET)
public String list(
@UserAuth UserAuth user,
Model model) {
if (!user.isAuthenticated()) {
return "redirect:http://www.test.com/login.jsp";
}
model.addAttribute("articles", listService.getLists());
return "list";
}
Estes funcionam da mesma forma. qual é a melhor maneira? e qual é a diferença?