2013-10-31 50 views
0

我正在使用struts 2,並且當點擊刷新按鈕時我想避免重複表單提交...從Action類獲得結果後,我回到相同的jsp和它保存輸入的值,並且它已成功提交的消息,但問題是,當我刷新頁面..它再次嘗試提交請求....因爲我試圖使用令牌攔截器在Struts 2可用...但我覺得我失去了一些東西......當點擊刷新按鈕時避免重複Struts2表單提交

<package name="FOCAccept" extends="struts-default"> 
    <action name="focSubmitRequest" class="bpel.invoke.action.FOCAcceptAction" method="execute"> 
     <interceptor-ref name="token"/> 
     <result name="invalid.token">/postfocaccept.jsp</result> 
     <result name="input">/postfocaccept.jsp</result> 
     <result name="success">/postfocaccept.jsp</result> 
     <result name="failure">/postfocaccept.jsp</result> 
     <result name="invalid" type="redirectAction">LogoutCred.action</result> 
    </action> 
</package> 
+2

見http://en.wikipedia.org/wiki/Post/Redirect/Get。 –

+1

http://stackoverflow.com/a/13529656/1654265 –

回答

-1

我用這個和它工作正常,我......無論如何,在它所有的事情是輸出。我已經在jsp中加入這一點,當我按下刷新按鈕,它沒有擊中控制,也使得輸入的字段值空..

這裏是代碼...... $(document).bind('keypress keydown keyup', function(e) {
if(e.which === 116) { $("#submitRequest_pon").val(""); $(".errorMessage").html(""); return false; } if(e.which === 82 && e.ctrlKey) {
return false; } });

+0

什麼是右鍵單擊 - >重新加載? –

+0

......當解決問題的時候,你的解決方案是劫持正常的瀏覽器功能嗎?! –

+0

thnaks的答覆...但如何2做..我試圖用令牌攔截器,但我失敗了......你能給一個代碼示例... –

相關問題