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

1.パラメータなし

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
@RequestMapping(value="/create",method = { RequestMethod.POST, RequestMethod.GET })
public String create(HttpServletResponse response){
return "redirect:/index";
}
@RequestMapping(value="/create",method = { RequestMethod.POST, RequestMethod.GET }) public String create(HttpServletResponse response){ return "redirect:/index"; }
@RequestMapping(value="/create",method = { RequestMethod.POST, RequestMethod.GET })  
public  String create(HttpServletResponse response){  
    return "redirect:/index";  
}

2.パラメータあり

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
@RequestMapping("/create")
public String create(Model model, RedirectAttributes attr) {
attr.addAttribute("username", "user008");
attr.addFlashAttribute("username", "user008");
return "redirect:/user/users";
}
@RequestMapping("/create") public String create(Model model, RedirectAttributes attr) { attr.addAttribute("username", "user008"); attr.addFlashAttribute("username", "user008"); return "redirect:/user/users"; }
@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