action中写
String form="123";
request.setAttribute("form",form);jsp中写
String form=(String)request.getAttribute(form);
out.println(form);
String form="123";
request.setAttribute("form",form);jsp中写
String form=(String)request.getAttribute(form);
out.println(form);
String username = request.getSession.SetAttribute("username",val);得:
String nameto= request.getSession().GetAttribute("username");
<bean:write name="form"/>
sql=" select * from some tables ";
PreparedStatement stmt = conn.prepareStatement(sql);
ResultSet rs = stmt.executeQuery();
ArrayList array=new ArrayList();
while (rs.next()) {
AActionForm actionForm =new AActionForm ();
actionForm.setId(rs.getString("Id"));
actionForm.setName(rs.getString("Name"));
array.add(actionForm);
}
request.setAttribute("array", array);
在Action 的Execute方法中,我们 把这个集合用request.setAttribute("array", array)存储起来,然后在JSP页面中,我们用iterate Tag把数据循环现实出来。代码通常都是这个样子:
<logic:present name=" array " scope="request">
<logic:iterate name=" array " id=" array "
type="com.bhsky.webis.Goods">
<tr align="center">
<td class="table2">
<bean:write name=" array " property="goodsid"/>
</td>
<td class="table2">
<bean:write name=" array " property="goodsname"/>
</td>
</tr>
</logic:iterate>
</logic:present>
《如何在Struts 数据库应用程序中实现分页显示(1) 》