0

以下の例を検討してください。これは、ステップフォームの非常に一般的なサンプルだと思います。アカウントから他のアカウントに送金したい3つのステップのフォームがあります:

First  page gets user source account
Second page shows source account and gets destination account and the amount
Last   page shows a confirmation which mention source account + destination account + amount

ご覧のとおり、最後のページにもモデル情報が必要です。そのため@BeginConversation、最初のアクションと@ConversationAction2 番目と最後のページに使用します。

問題は、私のアクションに の注釈が付けられていないこと@EndConversationです。大丈夫ですか?!モデルはメモリに常駐しますか、それとも自動クリーニングされますか? 自動クリーニングの時期がわかりませんでした。

4

1 に答える 1

2

同様の問題がありました。フォームの送信によって終了アクションが呼び出された場合、会話が既に閉じられているか期限切れであるというエラーが常に発生していました。

もちろん、会話を終了しなければ、メモリ リソースは解放されません。これに関する情報は、strut2 会話プラグイン サイト ( https://code.google.com/p/struts2-conversation/wiki/UsageGuide#Memory_Management ) で入手できます。

そこでは、会話スレッドの有効期限と同時に使用できるそれらの数に関連するいくつかのパラメーターを設定できることがわかります。

<!-- monitoring frequency in milliseconds -->
<constant name="conversation.monitoring.frequency" value="300000"/>

<!-- idle conversation timeout in milliseconds -->
<constant name="conversation.idle.timeout" value="28800000"/>

<!-- max instances of a conversation -->
<constant name="conversation.max.instances" value="20"/>

<!-- number of timeout monitoring threads -->
<constant name="conversation.monitoring.thread.pool.size" value="20"/>

とにかく、 @EndConversation タグを含むアクションを呼び出す最後のアクションにリダイレクト結果を追加して、この問題を解決しました。その中で、最後にしたい結果を設定しました。会話フィールド変数は引き続き正しく設定され、使用可能です。

@ConversationAction(conversations = "form")
@Action(value="formSecondLast", results={@Result(name=SUCCESS, type = "redirect", location="formLast")})
public String formSecondLast() throws Exception {
    //Here goes the code you want it to manipulate the conversation field data.
    //Maybe save to the database or send it to the business tier.
    return SUCCESS;
}

@EndConversation(conversations = "form")
@Action(value="formLast", results={@Result(name=SUCCESS, location="/jsp/form-end.jsp")})
public String formEnd() throws Exception {
    // This is a dummy action that does not do anything.
    // It is called just after formSecondLast ends and sends the user the jsp page.
    return SUCCESS;
}
于 2013-11-07T01:53:58.043 に答える