如题 就是我要点一下A页面按钮转到B页面 同时把A页面的一个变量转给B页面

解决方案 »

  1.   

    http://127.0.0.1/b.jsp?var=cc
    在B页面用<% request.getParameter("var");%>即可取的变量值  
      

  2.   

    正解,如果再要传到另外一个页面,就request.setAttribute("cc",cc);页面可以${cc}取出值
      

  3.   

    也可以用表单提交
    A.jsp
    <form method="post" name="form1" action="B.jsp">
    <input type="hidden" name="aa" value="aa"/>
    <input name="提交" type="submit" value="提交" /> 
    </form>
    B.jsp
    <%String aa=request.getParameter("aa"); %>
      

  4.   

    那个我需要JAVA实现的代码。JSP我看不懂
      

  5.   

    A 页面
    用户名:<input type="text" name="userName">在JAVA类里面 就可以
    String str=request.getparamter("userName");转到B页面
    用户名:${requestScope.userName}
      

  6.   

    request.getParameter()
       getParameter("param")函数为 获取参数param的值
    该函数是 request的函数,而加上request就是限定改参数param需要是请求范围内的参数
      

  7.   

    A页面
    <form method="post" name="form1" action="B.jsp?变量名a=<%=变量a %>">b页面
    string a = request.getParameter("变量a");
      

  8.   

    你是说在JAVABEAN里面获取表单值么?是的话就要导入javax.servlet.http.HttpServletRequest;和javax.servlet.http.*;这个两个包
      

  9.   

    request.getParameter(name);
    取参数名为name的值。
      

  10.   

    我还是不太明白
    //这个就是A页面的按钮
    public String button1_action() {
            //待办事项:执行此操作。返回值为某个导航
            //情况名称;如果返回值为空,将返回至同一页面        int a = 5;//比如这个就是要传的变量        return "case1";
        }
    B页面
    public void init() {
            // Perform initializations inherited from our superclass
            super.init();
            // Perform application initialization that must complete
            // *before* managed components are initialized
            // TODO - add your own initialiation code here
            //我要B页面一打开初始化的时候就把a值传过来所以代码应该是写在这个位置。
            //int b;
            //就是简单的把A页面的a赋值给b,该怎么做呢???????????????
            
            // <editor-fold defaultstate="collapsed" desc="Managed Component Initialization">
            // Initialize automatically managed components
            // *Note* - this logic should NOT be modified
            try {
                _init();
            } catch (Exception e) {
                log("simplyresult Initialization Failure", e);
                throw e instanceof FacesException ? (FacesException) e: new FacesException(e);
            }
            
            // </editor-fold>
            // Perform application initialization that must complete
            // *after* managed components are initialized
            // TODO - add your own initialization code here
        }
      

  11.   


    哥,很小心的问你一句,java页面是什么??不是JSP么?
      

  12.   

    我的是visual web jsf
    netbean里面项目新建一个visual web jsf页 出来以后有设计视图 JSP JAVA视图 JSP视图里的代码我看不懂 我都是点JAVA视图往里写东西的
      

  13.   

    于是谁告诉我怎么A页面点个按钮把A页面的一个值传给B页面阿。
    //这个就是A页面的按钮
    public String button1_action() {
            //待办事项:执行此操作。返回值为某个导航
            //情况名称;如果返回值为空,将返回至同一页面        int a = 5;//比如这个就是要传的变量        return "case1";
        }
    B页面
    public void init() {
            // Perform initializations inherited from our superclass
            super.init();
            // Perform application initialization that must complete
            // *before* managed components are initialized
            // TODO - add your own initialiation code here
            //我要B页面一打开初始化的时候就把a值传过来所以代码应该是写在这个位置。
            //int b;
            //就是简单的把A页面的a赋值给b,该怎么做呢???????????????
           
            // <editor-fold defaultstate="collapsed" desc="Managed Component Initialization">
            // Initialize automatically managed components
            // *Note* - this logic should NOT be modified
            try {
                _init();
            } catch (Exception e) {
                log("simplyresult Initialization Failure", e);
                throw e instanceof FacesException ? (FacesException) e: new FacesException(e);
            }
           
            // </editor-fold>
            // Perform application initialization that must complete
            // *after* managed components are initialized
            // TODO - add your own initialization code here
        }
      

  14.   

    OK了。。是我自己没搞明白我需要的根本不是JSP的session我需要的只是JAVA语言层面的一个全局的类而已。。
      

  15.   

    request.getparamter("userName");返回的object类型,要强制转换。
    String str=(String)request.getparamter("userName");