「Spring MVC」ViewResolverリダイレクトのサンプル

1.パラメータなし

@RequestMapping(value="/create",method = { RequestMethod.POST, RequestMethod.GET })  
public  String create(HttpServletResponse response){  
    return "redirect:/index";  
}

2.パラメータあり

@RequestMapping("/create")
public String create(Model model, RedirectAttributes attr) {
      attr.addAttribute("username", "user008");
    attr.addFlashAttribute("username", "user008");
      return "redirect:/user/users";
}

 

SpringMVC

Posted by arkgame