日期:2014-05-18  浏览次数:20890 次

struts的页面刷新问题,一个困扰了很久的问题,肯请大家帮忙
做的是翻页的数据显示,但是每次点击上一页或下一页,有时翻有时不翻,也就时并不是每次都进入struts的action里.
以前页做过类似的 "购物车 ",每次添加时,也是不是每次添加都进入struts的action里,有时添加错误,有时添加正确.
当点击按刷新按钮时,刷新页面都能出来正确的结果.但是每次刷新都重复执行上次的操作,这个也是我不想要得错误.

问题1.如何有效的解决每次不进入action里问题,让每次点击正确,并不是时进时不action进.

问题2.当点击刷新刷新按钮时,不让它自动增加,而是正确操作点击才增加.

////////这个时我得翻页的action.
public   ActionForward   execute(ActionMapping   mapping,   ActionForm   form,
HttpServletRequest   request,   HttpServletResponse   response)   {
//   TODO   Auto-generated   method   stub
int   perRows   =   10;
String   currPage   =   request.getParameter( "page ");
if   (currPage   ==   null)   {
Page   p   =   new   Page(1,   perRows,   "Orders ",
"OrderID,CustomerID,shipVia,shipName ",   "OrderID ",   " ",   " ");
ArrayList   arr   =   p.getArrayList();
if   (arr   !=   null)   {
request.setAttribute( "page ",   arr);
request.getSession().setAttribute( "pagelist ",   p);
}
arr=null;
p   =   null;
}   else   if   (currPage   !=   null)   {
if   ( "Next ".equals(currPage))   {
Page   p   =   (Page)   request.getSession().getAttribute( "pagelist ");
p.setCurrPage(p.getCurrPage()   +   1);
ArrayList   arr   =   p.getArrayList();
if   (arr   !=   null)   {
request.setAttribute( "page ",   arr);
request.getSession().setAttribute( "pagelist ",   p);
}
arr=null;
p=null;
}else   if( "Prev ".equals(currPage)){
Page   p=(Page)request.getSession().getAttribute( "pagelist ");
p.setCurrPage(p.getCurrPage()-1);
ArrayList   arr=p.getArrayList();
if(arr!=null){
request.getSession().setAttribute( "pagelist ",p);
request.setAttribute( "page ",   arr);
}
arr=null;
p=null;
}else   if( "start ".equals(currPage)){
Page   p=(Page)request.getSession().getAttribute( "pagelist ");
p.setCurrPage(1);
ArrayList   arr=p.getArrayList();
if(arr!=null){
request.setAttribute( "page ",arr);
request.getSession().setAttribute( "pagelist ",p);
}
arr=null;
p=null;
}else   if( "end ".equals(currPage)){
Page   p=(Page)request.getSession().getAttribute( "pagelist ");
p.setCurrPage(p.getTotalPage());
ArrayList   arr=p.getArrayList();
if(arr!=null){
request.getSession().setAttribute( "pagelist ",p);
request.setAttribute( "page ",arr);
}
arr=null;
p=null;
}
}
return   mapping.findForward( "page ");
}

////////////这个是jsp页面的代码
    <body>
        This   is   my   JSP   page.   <br/>
        <table   border= "1 "   whidth= "100% ">
        <tr>
        <th> OrderID </th> <th> CustomerID </th> <th> shipVia </th> <th> shipName </th>
        </tr>
        <logic:notEmpty   scope=