主頁(yè) > 知識(shí)庫(kù) > JSP刷新頁(yè)面表單重復(fù)提交問題解決辦法分享

JSP刷新頁(yè)面表單重復(fù)提交問題解決辦法分享

熱門標(biāo)簽:高德地圖標(biāo)注樣式 商洛電銷 四川保險(xiǎn)智能外呼系統(tǒng)商家 電銷機(jī)器人好賣么 地圖標(biāo)注線上教程 杭州語(yǔ)音電銷機(jī)器人軟件 電銷機(jī)器人是有一些什么技術(shù) 北票市地圖標(biāo)注 杭州ai語(yǔ)音電銷機(jī)器人功能

使用sessionID和時(shí)間戳作為標(biāo)識(shí),關(guān)鍵代碼如下:

復(fù)制代碼 代碼如下:

public class SswpdjAction extends BaseAction{

      public String execute(){
        /**業(yè)務(wù)代碼**/
        ................
        //設(shè)置標(biāo)識(shí)
        this.setSessionToken();
        //轉(zhuǎn)到添加頁(yè)面
        return "toAdd";
      }
  
      public String reSave(){
        if(this.token != null this.token.equals(this.getSessionToken())){
          /**設(shè)置新標(biāo)識(shí)**/
          this.setSessionToken();
      
          /**業(yè)務(wù)代碼**/
          ..............
          return "toAdd";
        }else{
          printWriter out = null;
          try{
            httpServletResponse.setContentType("text/html;charset=UTF-8");
            out = httpServletResponse.getWriter();
            out.println("script>alert('刷新提交表單!');/script>");
            out.flush();
        
            }catch(IOException e){
                e.printStackTrace();
            }finally{
                if(out != null){
                    out.close();
                }
            }
        }
        return null;
  }
}

public class BaseAction extends ActionSupport{

    /**jsp頁(yè)面標(biāo)識(shí)**/
    protected String token;

    public String getToken(){
        return token;
    }

    public void setToken(String token){
        this.token = token;
    }

    public String getSessionToken(){
        if(null != httpSession.getAttribute("Token")){
            return httpSession.getAttribute("Token");
        }else{
            return null;
        }
    }

    /**標(biāo)識(shí)生成**/
    public void setSessionToken(){
        String flag = useMd5(httpSession.getId() + System.currentTimeMillis());
        httpSession.setAttribute("Token", flag);
        httpServletRequest.setAttribute("SessionToken", flag);
    }

    /**MD5加密**/
    private String useMd5(String str){
        byte[] bs = str.getBytes();
        String result = null;
        try{
            MessageDigest md5 = MessageDigest.getInstance("MD5");
            md5.update(bs);
            result = md5.digest().toString();
        }catch(NoSuchAlgorithmException e){
            e.printStackTrace();
        }finally{

        }
        return result;
    }
}

JSP頁(yè)面設(shè)置標(biāo)識(shí)隱藏域:

復(fù)制代碼 代碼如下:

form>
  input type="hidden" name="token" value="${SessionToken}" />
/form>

您可能感興趣的文章:
  • js防止表單重復(fù)提交的兩種方法
  • javascript下阻止表單重復(fù)提交、防刷新、防后退
  • js防止表單重復(fù)提交實(shí)現(xiàn)代碼
  • js控制再次點(diǎn)擊按鈕之間的間隔時(shí)間可防止重復(fù)提交
  • JSP防止網(wǎng)頁(yè)刷新重復(fù)提交數(shù)據(jù)的幾種方法
  • JavaScript實(shí)現(xiàn)點(diǎn)擊按鈕后變灰避免多次重復(fù)提交
  • JS Ajax請(qǐng)求如何防止重復(fù)提交
  • jsp 重復(fù)提交問題
  • 一個(gè)JavaScript防止表單重復(fù)提交的實(shí)例
  • 前端防止用戶重復(fù)提交js實(shí)現(xiàn)代碼示例

標(biāo)簽:宿州 青島 江西 紅河 西藏 丹東 云浮 貴州

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《JSP刷新頁(yè)面表單重復(fù)提交問題解決辦法分享》,本文關(guān)鍵詞  JSP,刷新,頁(yè)面,表單,重復(fù),;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《JSP刷新頁(yè)面表單重復(fù)提交問題解決辦法分享》相關(guān)的同類信息!
  • 本頁(yè)收集關(guān)于JSP刷新頁(yè)面表單重復(fù)提交問題解決辦法分享的相關(guān)信息資訊供網(wǎng)民參考!
  • 企业400电话

    智能AI客服机器人
    15000

    在线订购

    合计11份范本:公司章程+合伙协议+出资协议+合作协议+股权转让协议+增资扩股协议+股权激励+股东会决议+董事会决议

    推薦文章