分页与输入错误后的错误验证在同一个页面的时候的解决办法

因为分页的信息与错误验证在同一个页面,如果错误验证来刷新页面,分页的页面被刷新了肯定会出错的,所以就必须要让分页的页面在错误验证之前就刷新一次,具体方法看下面:

else if(protectListType.equals("protectListDeleteButton"))
  {
   SQLBean sb=new SQLBean();
   if(sb.isDeleteProtectList(protectListForm))
   {
    // 保护名单删除合法
    System.out.println("保护名单验证成功,允许删除");
    request.setAttribute("protectListDeleteData",protectListForm);
    try 
    {
     servlet.getServletContext().getRequestDispatcher("/ProtectListPage.do").forward(request, response);
     return null ;
    } 
    catch (ServletException e) 
    {
     e.printStackTrace();
    } 
    catch (IOException e) 
    {
     e.printStackTrace();
    }
   }
   else
   {
    // 错误,要回到ProtectList页面
    ActionMessages errors = new ActionMessages() ;

    System.out.println("保护名单验证未成功,不允许删除");
    if(protectListBrandNumberInput!=null||!"".equals(protectListBrandNumberInput))
    {
     errors.add("errorProtectList",new ActionMessage("error.ProtectList")) ;
     super.saveErrors(request, errors) ;
     try 
     {
      servlet.getServletContext().getRequestDispatcher("/ProtectListPage.do").forward(request, response);
      return null ;
     } 
     catch (ServletException e) 
     {
      e.printStackTrace();
     } 
     catch (IOException e) 
     {
      e.printStackTrace();
     }
     return mapping.getInputForward() ;
    }
   }
  }

 这是当点了删除按钮之后的一系列操作,其中在super.saveErrors(request, errors) ;下边加了重新分页的语句,重新分页也就是重新刷新了一次页面,然后再return mapping.getInputForward() ;就不会出错而且会把错误信息显示出来了

 

黑色头发  http://heisetoufa.iteye.com

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值