2012-01-30 3 views

答えて

4

POSTを追加することはできませんが、GETを使用してリダイレクトすることはできます。次の操作を行います。ポストが不可能なのはなぜ

@RequestMapping("/redirectMe") 
public void redirectMe (HttpServletResponse response){ 
    response.sendRedirect("http://redirected.com/form?someGetParam=foo"); 
} 
+0

のようなものですか?私はパラメータが生成されたときコレクションを取得するときに問題があります。URLは 'http:// localhost:8080/myApp/A/result.form?parameters = SomeName&parameters = SoemField'で' parameters = SomeName'になります。何か案が? – Betlista

+0

この質問に記載されているように、リダイレクトするようにブラウザに指示すると、どのhttp動詞が使用されているかを定義することはありません。常にGETになります。 POSTが必要な場合は、JavaScriptクライアントを展開してクロスサイトスクリプティングを行わないようにする必要があります。 – aweigold

1

この

@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"; 
} 
関連する問題