国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開APP
userphoto
未登錄

開通VIP,暢享免費(fèi)電子書等14項(xiàng)超值服

開通VIP
struts2避免重復(fù)提交
struts2使用攔截器來檢查表單是否重復(fù)提交,它采用同步令牌的方式來實(shí)現(xiàn)對表單重復(fù)提交的判斷。
首先需要在表單中使用<s:token name="user.token"></s:token>
<s:token>標(biāo)簽創(chuàng)建一個新的令牌值,并用你所指定的令牌名把令牌保存到session中。而這個令牌值是隨即產(chǎn)生的經(jīng)過加密的字符序列,不會重復(fù)。struts2使用攔截器來檢查表單是否重復(fù)提交,它采用同步令牌的方式來實(shí)現(xiàn)對表單重復(fù)提交的判斷。
首先需要在表單中使用
 
其次需要為action配置TokenInterceptor或者TokenSessionStoreInterceptor攔截器。這兩個攔截器都已經(jīng)在struts-default.xml中定義,但沒有包含在defaultStack攔截器棧中。
在action中配置攔截器和在重復(fù)提交時,將要請求導(dǎo)向的結(jié)果視圖。
<action name="register" class="com.zhaosoft.action.RegisterAction">
      <!-- 配置異常映射,當(dāng)RegisterAction拋出Exception異常時,向用戶顯示error.jsp頁面 -->
      <exception-mapping result="error" exception="java.lang.Exception"/>
<result name="invalid.token">/WEB-INF/pages/register.jsp</result>
      <result name="input">/WEB-INF/pages/register.jsp</result>
      <result name="success">/WEB-INF/pages/success.jsp</result>
      <result name="error">/WEB-INF/pages/error.jsp</result>
      <interceptor-ref name="defaultStack">
      <param name="workflow.excludeMethods">default</param>
      </interceptor-ref>
      <interceptor-ref name="token">
         <param name="excludeMethods">default</param>
      </interceptor-ref>
    </action>
注:excludeMethods指定要排除的方法。
在register.jsp頁面中添加action級別的錯誤信息顯示的標(biāo)簽:<s:actionerror/>
在form中添加<s:token>標(biāo)簽:<s:token name="user.token"></s:token>
最好為在資源文件中設(shè)置鍵struts.messages.invalid.token的本地化消息。
struts.messages.invalid.token=您已經(jīng)提交了表單,請不要重復(fù)提交。
TokenSessionStoreInterceptor:使用TokenSessionStoreInterceptor攔截器同樣能避免重復(fù)提交,TokenSessionStoreInterceptor集成自TokenInterceptor。使用TokenSessionStoreInterceptor將不會輸出任何錯誤信息。如果token無效,請求被導(dǎo)向到invalid.token結(jié)果碼映射的視圖。
配置如下:
<interceptor-ref name="tokenSession">
         <param name="excludeMethods">default</param>
      </interceptor-ref>
 
本文來自CSDN博客,轉(zhuǎn)載請標(biāo)明出處:http://blog.csdn.net/king2232/archive/2008/09/19/2949102.aspx
本站僅提供存儲服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點(diǎn)擊舉報。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
Struts2防止表單重復(fù)提交
struts2.x中的<s:token/>標(biāo)簽
struts2之防止表單重復(fù)提交
action中配置攔截器,表單重復(fù)提交問題
使用Struts的Token機(jī)制解決表單的重復(fù)提交
Struts解決表單重復(fù)提交問題
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長圖 關(guān)注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服