81,094
社区成员
发帖
与我相关
我的任务
分享
1、在a.jsp中,一个表单<form>提交到servlet,查询到一组数据list,放在request中,然后转发到b.jsp,这样是ok的;
2、现在在a.jsp中添加一个<frame />,把b.jsp放在<frame />里,其他不变,但是数据丢失了,怎么解决啊?
a.jsp:
<form action="Test" target="content_frame" method="post" name="form1">
<table border="1" width="60%" cellpadding="1" cellspacing="1">
<tr>
<td>
姓名查找:<input type="text" id="t1" name="uname"/>
年龄查找:<input type="text" id="t2" name="age"/>
<input type="submit" value="查询" />
</td>
</tr>
</table>
<iframe name="content_frame" marginwidth=0 marginheight=0 width=100% height=30 frameborder=0/>
</form>
<table border="1" width="60%">
<tr><td>学号</td><td>姓名</td><td>年龄</td></tr>
<c:forEach items="${requestScope.students }" var="st">
<tr>
<td>${st.id }</td>
<td>${st.name }</td>
<td>${st.age }</td>
</tr>
</c:forEach>
</table>
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String uname = request.getParameter("uname");
String age = request.getParameter("age");
StudentDAO std = new StudentImpl();
request.setAttribute("students", std.findByNameAndTel(uname, age));
request.getRequestDispatcher("/b.jsp").forward(request, response);
}