1.第一个jsp页面

<form ></form>


2.第二个jsp页面,根据第一个页面提交的balance的值,如果是小雨500,则在第一个页面处理,否则转发给第二个页面,其中使用setAttribute设置参数

<body>
<%
String bal = request.getParameter("balance");
double piaozi = Double.parseDouble(bal);
if (piaozi < 500) {
out.println("给你" + piaozi + "元");
out.println("剑豪" +piaozi + "元");
} else {
List<String> info = new ArrayList<String>();
info.add("1111");
info.add("2222");
info.add("3333");
request.setAttribute("info", info);
%>
<jsp:forward page="second.jsp" />
<%
}
%>
</body>

3.第三次页面,使用request.getAttribute获取属性


<body>
<%
String bal = request.getParameter("balance");
double piaozi = Double.parseDouble(bal);
if (piaozi < 500) {
out.println("给你" + piaozi + "元");
out.println("剑豪" +piaozi + "元");
} else {
List<String> info = new ArrayList<String>();
info.add("1111");
info.add("2222");
info.add("3333");
request.setAttribute("info", info);
%>
<jsp:forward page="second.jsp" />
<%
}
%>
</body>


4. 在一个页面输入600结果如下

1111
2222
3333
给您600.0元 减少600.0元

相关文章:

  • 2022-12-23
  • 2021-06-29
  • 2022-02-06
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-01-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-22
  • 2022-12-23
相关资源
相似解决方案