-

Redirect After Post

Redirect After Post

Redirect After Post ってあんまり意識しなかったけど、たいがいのログインフォームとかでも、リダイレクトか、metaタグによるリフレッシュになってるな。

This approach provides a clean Model-View-Controller solution. All input data is stored, permanently or temporarily, in the Model on the server during the first step. The second step loads a View reflecting current Model state.

これはDouble Submit Problemを防止するのだが、MVCにも合っていると。

  • POSTでModelの状態を変化させる(first step)
  • GETで変化したModel状態を反映したViewを見せる(second step)

なるほど。

ついでにこのときのリダイレクトのステータスコードは303("See Other")が正しいってのも覚えとこ。HttpResponse.sendRedirect() では302。