2012-03-23 11 views
0

私は1つのURLでフォームを送信してブラウザにデフォルトのURLを表示できるように、コントローラのメソッドをリダイレクトしたいと思っています。このようにsomethignは戻り値の型postFormsを変更し、モデルとビュー/ redirectview:Springリダイレクト要求マッピング

@RequestMapping(value = "/Home", method = RequestMethod.GET) 
public String getHome(Model model){ 
    //view name append with .jsp 
    return "myHome"; 
} 

@RequestMapping(value = "/FormA", method = RequestMethod.POST) 
public String postFormA(Email Email, Model model){ 
    //do stuff then 
    //redirect to different requestMapping broswer url "/Home" 
    getHome()  
} 

@RequestMapping(value = "/FormB", method = RequestMethod.POST) 
public String postFormB(Model model){ 
    //do stuff then 
    //redirect to different requestMapping and display in broswer url "/Home" 
    getHome() 
} 

答えて

3

どのようにこのようなものについて:

@RequestMapping(value = "/Home", method = RequestMethod.GET) 
public ModelAndView getHome(){ 
    //view name append with .jsp 
    return new ModelAndView("myHome"); 
} 

@RequestMapping(value = "/FormA", method = RequestMethod.POST) 
public String postFormA(Email Email, Model model){ 
    //do stuff then 
    //redirect to different requestMapping broswer url "/Home" 
    return "redirect:/Home"; 
} 

@RequestMapping(value = "/FormB", method = RequestMethod.POST) 
public String postFormB(Model model){ 
    //do stuff then 
    //redirect to different requestMapping and display in broswer url "/Home" 
    return "redirect:/Home"; 
} 
関連する問題