在网上看已仁兄说这样可以传数组,按照他的方法去做,结果不知道哪错了,老是空指针
dingdang11.jsp部分代码:
String[] str=new String[99];
for(;i>str.length;i++){
ResultSet rs_orderid=conn.executeQuery("select orderid from order_item where username='"+session.getAttribute("username")+"' and teaid='"+id+"' and number='"+number+"' and price='"+price+"' ");
while(rs_orderid.next()){
int orderid=rs_orderid.getInt(1);
str[i]=(String)orderid;dingdang12.jsp部分代码:String[] str=(String[])session.getAttribute( "str");
out.print(str.length);
断电测试发现str是空的。该怎么改?
dingdang11.jsp部分代码:
String[] str=new String[99];
for(;i>str.length;i++){
ResultSet rs_orderid=conn.executeQuery("select orderid from order_item where username='"+session.getAttribute("username")+"' and teaid='"+id+"' and number='"+number+"' and price='"+price+"' ");
while(rs_orderid.next()){
int orderid=rs_orderid.getInt(1);
str[i]=(String)orderid;dingdang12.jsp部分代码:String[] str=(String[])session.getAttribute( "str");
out.print(str.length);
断电测试发现str是空的。该怎么改?
你在哪里使用setAttribute了?
while(rs_orderid.next()){
int orderid=rs_orderid.getInt(1);
str[i]=(String)orderid;}
session.setAttribute("str",str);
设置Attribute的方法 session.setAttribute("键","值")
获得Attribute的方法 session.getAttribute("键")