因为分页的信息与错误验证在同一个页面,如果错误验证来刷新页面,分页的页面被刷新了肯定会出错的,所以就必须要让分页的页面在错误验证之前就刷新一次,具体方法看下面:
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() ;就不会出错而且会把错误信息显示出来了