jsp request.getAttribute 中如何取值?

来源:百度知道 编辑:UC知道 时间:2024/06/18 09:17:23
<logic:equal name="reportForm" property="viewFlg" value="2">
<table width="765" cellpadding=2 cellspacing=0 border=1 align="center" class="table_style_100">
<tr class="tr_title">
<%
String storeName[] = (String[])request.getAttribute("allhead");
String allbody[][] = (String[][])request.getAttribute("allbody");
%>

<td nowrap width="2%" class="td_titletr"><bean:write name="commitDateListView" property="storeName[]" /></td>

<td nowrap width="2%" class="td_titletr"><bean:write name="commitDateListView" property="allbody[][]" /></td>
</tr>
</table>
</logic:equal>

jsp request.getAttribute是通过key来获取value的。
比如
SelRs rsSr=(SelRs)request.getAttribute("oaSr");
String dbType=(String)request.getAttribute(WebKeys.DbType);
这两句话是同一个意思..
SelRs rsSr=(SelRs)request.getAttribute("oaSr");是获得request.setAttribute("oaSr",对象);中的对象;而String dbType=(String)request.getAttribute(WebKeys.DbType); 是获得request.setAttribute("**","值");**和WebKeys.DbType的值一样;

request.setAttribute("allhead",字符串数组)
request.setAttribute("allhead",字符串二维数组)

你已经取出来了 在storName和allbdoy中

先set才能get啊!
request.setAttribute("allhead",字符串数组);之后再
request.getAttribute("allhead",字符串数组);

request.setAttribute("allhead",字符串数组)
request.setAttribute("allhead",字符串二维数组)

你已经取出来了 在storName和allbdoy中

可以具体的点吗?
getAttribute
已经得到一个对象了,还要取什么值

赋值后取键值就可以了