返却方法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;
}
文字列を返す方法
@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";
}
これらは同じように機能します。どちらが良い方法ですか?違いは何ですか?