最简单方法用location和history实现,再不你就传参数过去,例如当前第几页。然后换回的时候带个从第几页过来的。并且你说的这种情况是不会出现的,A,B不会在同一台机器上操作吧,互相是不会影响的

解决方案 »

  1.   

    history用过,不行
    现在就是用的location<a href="javascript:void(0);" onclick="location.replace('customerSerch.do?method=backCustomerXx')">
      

  2.   

    你的信息存储方式呢?   
    后台存储信息的方式可能不对,一般存储到session中   ,就不会出现这种情况了.  
    我看你的问题的感觉是,似乎所有用户都在对一个信息进行操作....
     
      

  3.   

    楼主,试试点查看的时候,把查询条件保存在 js 的 cookie 中,点 返回 的时候 重新读 cookie
      

  4.   

    查询啊还存储过程干啥啊,用不着事务的,就找普通sql分页查询不就好了
      

  5.   

    我就不从数据库读数据了  直接模拟数据了哈小于1页和大于最大页数 我懒得判断了  重在理解...用的struts2
    package com.zzab.action;import java.util.Map;import javax.servlet.ServletContext;
    import javax.servlet.http.HttpServletResponse;import org.apache.struts2.ServletActionContext;import com.opensymphony.xwork2.ActionContext;public class BaseAction {


    public Map<String,Object> getRequest(){
    return (Map)ActionContext.getContext().get("request");
    }

    public Map<String,Object> getApplication(){
    return (Map)ActionContext.getContext().getApplication();
    }

    public Map<String,Object> getSession(){
    return (Map)ActionContext.getContext().getSession();
    }

    public HttpServletResponse getResponse(){
    HttpServletResponse response = ServletActionContext.getResponse();
    response.setCharacterEncoding("uft-8");
    response.setContentType("text/html;charset=utf-8");
    return response;
    }
    }package com.zzab.action;import java.util.List;import com.zzab.bean.Employee;
    import com.zzab.service.EmployeeService;public class EmployeeAction extends BaseAction {

    private int nowPage; public int getNowPage() {
    return nowPage;
    } public void setNowPage(int nowPage) {
    this.nowPage = nowPage;
    }


    public String showEmployee(){

    List<Employee> list = EmployeeService.getEmployeeByPage(nowPage);
    this.getSession().put("list", list);
    return "success";
    }


    }
    package com.zzab.bean;public class Employee {
    private int id;
    private String name;
    private String phone;
    public int getId() {
    return id;
    }
    public void setId(int id) {
    this.id = id;
    }
    public String getName() {
    return name;
    }
    public void setName(String name) {
    this.name = name;
    }
    public String getPhone() {
    return phone;
    }
    public void setPhone(String phone) {
    this.phone = phone;
    }
    public Employee() {
    super();
    // TODO Auto-generated constructor stub
    }
    public Employee(int id, String name, String phone) {
    super();
    this.id = id;
    this.name = name;
    this.phone = phone;
    }
    }package com.zzab.service;import java.util.ArrayList;
    import java.util.List;import com.zzab.bean.Employee;public class EmployeeService {


    public static List<Employee> getEmployees(){
    List<Employee> employees = new ArrayList<Employee>();
    for (int i = 0; i < 20; i++) {
    Employee employee = new Employee(i, "张三" + i, "135" + i);
    employees.add(employee);
    }
    return employees;
    }


    public static List<Employee> getEmployeeByPage(int nowPage){
    List<Employee> employees = getEmployees();
    List<Employee> list = new ArrayList<Employee>();
    int index = 0;
    for (int i = (nowPage * 10); i < employees.size(); i++) {

    if(index == 10){
    break;
    }
    list.add(employees.get(i));
    index ++;
    }
    return list;
    }



    }
    stru.xml文件的内容<?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd">
    <struts><package  namespace="/test" name="default" extends="struts-default">
    <action name="show" class="com.zzab.action.EmployeeAction" >
    <result name="success">/employee.jsp</result>
    </action>
    </package>
    </struts>    <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
    <%@ taglib uri="/struts-tags" prefix="s" %>
    <%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
    %><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
      <head>
        <base href="<%=basePath%>">
        
        <title>My JSP 'employee.jsp' starting page</title>
        
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">    
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <!--
    <link rel="stylesheet" type="text/css" href="styles.css">
    -->  </head>
      
      <body>
      <table>
       <tr>
       <td>id</td>
       <td>name</td>
       <td>phone</td>
       <td>action</td>
       </tr>
       <s:iterator var="employee" value="#attr.list">
       <tr>
       <td>${employee.id }</td>
       <td>${employee.name }</td>
       <td>${employee.phone }</td>
       <td></td>
       </tr>
       </s:iterator>
      
      </table>
      <a href="test/show!showEmployee?nowPage=${nowPage-1 }">上一页</a>
       <a href="test/show!showEmployee?nowPage=${nowPage+1 }">下一页</a>
      </body>
    </html><%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
    <%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
    %><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
      <head>
        <base href="<%=basePath%>">
        
        <title>My JSP 'index.jsp' starting page</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">    
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <!--
    <link rel="stylesheet" type="text/css" href="styles.css">
    -->
      </head>
      
      <body>
    <a href="test/show!showEmployee">ccc</a>
      </body>
    </html>这就是基本的全部了...web.xml就不用我发了吧  汗 
      

  6.   

    感谢 RainOnl 提供的思路,以前没做过已经解决,将需要保存的信息如 要返回的sql,总页码  当前页等信息 put到 HashMap 中
    然后 将hashmap 存储 到session中当需要返回原来页面,调用返回原页面所操作的servlet 取得session中的相应信息,根据获取信息,再次查询出最初信息,并给JSP页面。PS 我将分页 操作 专门做到一个类中的。感谢  RainOnl !