不同页面之间利用表单javaBean传递数据
代码如下:a.jsp:<jsp:useBeanid="myBean"scope="request"class="com.bean"><jsp:setPropertynam...
代码如下:
a.jsp:
<jsp:useBean id="myBean" scope="request" class="com.bean">
<jsp:setProperty name="myBean" property="sideA" param="textfield" />
<jsp:setProperty name="myBean" property="sideB" param="textfield2" />
</jsp:useBean>
<form id="form1" name="form1" method="post" action="b.jsp">
<input type="text" name="textfield" size="10" />
<input type="text" name="textfield2"size="10" />
<input type="submit" name="Submit" value="提交" />
b.jsp:
<jsp:useBean id="myBean" scope="request" class="com.bean">
</jsp:useBean>
<%=myBean.getSideA() %>
<%=myBean.getSideB() %>
<%=myBean.area()%>
但是却不行,不知哪儿的问题...... 展开
a.jsp:
<jsp:useBean id="myBean" scope="request" class="com.bean">
<jsp:setProperty name="myBean" property="sideA" param="textfield" />
<jsp:setProperty name="myBean" property="sideB" param="textfield2" />
</jsp:useBean>
<form id="form1" name="form1" method="post" action="b.jsp">
<input type="text" name="textfield" size="10" />
<input type="text" name="textfield2"size="10" />
<input type="submit" name="Submit" value="提交" />
b.jsp:
<jsp:useBean id="myBean" scope="request" class="com.bean">
</jsp:useBean>
<%=myBean.getSideA() %>
<%=myBean.getSideB() %>
<%=myBean.area()%>
但是却不行,不知哪儿的问题...... 展开
2个回答
2011-05-13
展开全部
用scope="request"时,你跳转到b.jsp时,a.jsp创建的myBean早就销毁了(请求完成后销毁),所以得放到用户全局中去,得用session范围
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询