私はweb appのフォーラムを作成しています。メインページには、新しいスレッドを検索して作成するためのトピックとボタンがすべて表示されます。ユーザーがこの最後のボタンをクリックすると、新しいトピックのデータを入力するフォームが表示されます。ユーザーがクリックを送信すると、私はDBで、この新しいスレッドを格納し、私はメインページを示しアクションにリダイレクト:struts 2リダイレクトjava.lang.IllegalStateException
< action name="showForum" class="es.busco.colegio.actions.ForumAction" method="show">
< result name="success">/WEB-INF/jsp/forum.jsp< /result>
< /action>
< action name="newTopic" class="es.busco.colegio.actions.ForumAction" method="newTopic">
< result name="success">/WEB-INF/jsp/newTopic.jsp< /result>
< /action>
< action name="createTopic" class="es.busco.colegio.actions.Forumction" method="insert">
< result name="success" type="redirect">http://www.buscocolegio.com/Colegio/showForum.action< /result>
</ action>
問題は、新しいトピックをDBに二度挿入し、ログjava.lang.IllegalStateException
私はそれが二回挿入されています理由です、BDでの挿入よりも、サービスコールオブジェクトを実行した後、プログラムの実行がバックメソッドの初めに来る参照してデバッグするとき:
try{
Date d=new Date();
SimpleDateFormat sdf=new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
String s=sdf.format(d);
Date d1=sdf.parse(s);
topic.setDate(d1);
topic.setText(topic.getText().replaceAll("\n", "<br>"));
topicService.createTopic(topic);
}catch (Exception ex){
logger.error("Error: "+ex,ex);
return Action.ERROR;
}
return Action.SUCCESS;
}
のでtopicServiceを実行した後、 .createTopic (トピック);それはDate d = new Date();に戻ります。
誰でも知っているのはなぜですか?
あなたはアプリケーションのデバッグを試みて、なぜこれが起こっているのかを知りませんでした。 –
また、FirefoxやChromeではなく、IE上でのみ発生します... – user1383951