8
我想從彈簧控制器用post參數重定向到另一個頁面(在我的應用程序之外)。我搜索了很多,但沒有任何解決方案。從彈簧控制器重定向到post參數
我想從彈簧控制器用post參數重定向到另一個頁面(在我的應用程序之外)。我搜索了很多,但沒有任何解決方案。從彈簧控制器重定向到post參數
您將無法添加POST,但可以使用GET進行重定向。請執行以下操作:
@RequestMapping("/redirectMe")
public void redirectMe (HttpServletResponse response){
response.sendRedirect("http://redirected.com/form?someGetParam=foo");
}
做這樣的事情
@RequestMapping(value="/someUrl",method=RequestMethod.POST)
public String myFunc(HttpServletRequest request,HttpServletResponse response,Map model){
//do sume stuffs
return "redirect:/anotherUrl"; //gets redirected to the url '/anotherUrl'
}
@RequestMapping(value="/anotherUrl",method=RequestMethod.GET)
public String myAnotherFunc(HttpServletRequest request,HttpServletResponse response){
//do sume stuffs
return "someView";
}
後爲什麼不可能?我有收集時得到的問題,因爲參數生成的URL是:'http:// localhost:8080/myApp/A/result.form?parameters = SomeName&parameters = SoemField'這會導致'parameters = SomeName'。任何想法? – Betlista 2012-03-26 06:58:06
當您建議瀏覽器重定向時,如本問題所述,無法定義正在使用哪個http動詞。它將永遠是一個GET。如果您需要POST,您將需要部署一個JavaScript客戶端來執行此操作,並且您需要確保您沒有執行跨站點腳本。 – aweigold 2012-03-26 14:17:44