IndexSomeObject so=new IndexSomeObject();//get() set()方法
List<IndexSomeObject> someList =new ArrayList <IndexSomeObject>();so.setIlh(rs.getString("lh"));
so.setIpm(rs.getString("pm"));
so.setIgg(rs.getString("gg"));
someList.add(so);//session
request.getSession().setAttribute("someListi", someList);在下个Action里面存
下面取应该怎么取! 我这样取好象不行!!下的的list应该怎样取
还有怎么在最后销毁上面的sessionString spm="";
String sgg="";
String slh="";
IndexSomeObject so1 =new IndexSomeObject();//get() set()方法
List<IndexSomeObject> list = new ArrayList<IndexSomeObject>();
list=(List)request.getAttribute("someListi");
for(int i=0;i<list.size();i++){
spm=so1.getIpm("ipm");
sgg=so1.getIgg("igg");
slh=so1.getIlh("ilh");
}
IndexSomeObject so=new IndexSomeObject();//get() set()方法
List <IndexSomeObject> someList =new ArrayList <IndexSomeObject> (); so.setIlh(rs.getString( "lh "));
so.setIpm(rs.getString( "pm "));
so.setIgg(rs.getString( "gg "));
someList.add(so); //session
request.getSession().setAttribute( "someListi ", someList); 在下个Action里面存
下面取应该怎么取! 我这样取好象不行!!下的的list应该怎样取
还有怎么在最后销毁上面的session String spm= " ";
String sgg= " ";
String slh= " ";
IndexSomeObject so1 =new IndexSomeObject();//get() set()方法
List <IndexSomeObject> list = new ArrayList <IndexSomeObject> ();
list=(List)request.getAttribute( "someListi ");
for(int i=0;i <list.size();i++){
spm=so1.getIpm( "ipm ");
sgg=so1.getIgg( "igg ");
slh=so1.getIlh( "ilh ");
}
list=(List)request.getAttribute( "someListi "); 你放在了session里,然后想从request中取出来,这要是能取道就奇怪了
List <IndexSomeObject> list = new ArrayList <IndexSomeObject> ();
list=(List)request.getAttribute( "someListi ");
for(int i=0;i <list.size();i++){
so1 =(IndexSomeObject )list。get(i);
spm=so1.getIpm( );
sgg=so1.getIgg( );
slh=so1.getIlh(); }
String spm= " ";
String sgg= " ";
String slh= " ";
//IndexSomeObject so1 =new IndexSomeObject();//get() set()方法
List <IndexSomeObject> list = new ArrayList <IndexSomeObject> ();
list=(List)request.getAttribute( "someListi ");
for(int i=0;i <list.size();i++){
//上面注释了的代码放到这里
IndexSomeObject so1 =new IndexSomeObject();
//因为你在集合中存放的是IndexSomeObject所以你通过下表获取的是IndexSomeObject对象
so1=list.get(i);
spm=so1.getIpm( ); //然后在从对象中获取属性就可以了
sgg=so1.getIgg( );
slh=so1.getIlh();
//在这里打印出来就可以了
}
//这是销毁session的方法
session.invalidate();
要数据太多 程序会卡死的~~你这个直接这样就好
request.setAttribute( "someListi ", someList)
我上面贴的代码要吧request改为session(呵呵 ~~~~ 是复制LZ的代码 然后拿来修改 没看清)
二楼说的没错,“你放在了session里,然后想从request中取出来,这要是能取道就奇怪了”
把request该为session就可以了
//提示The method getIpm() in the type IndexSomeObject is not applicable for the arguments (String)String spm="";
String sgg="";
String slh="";
List<IndexSomeObject> list = new ArrayList<IndexSomeObject>();
list=(List<IndexSomeObject>)request.getSession().getAttribute("someListi");
for(int i=0;i<list.size();i++){
IndexSomeObject so1 =new IndexSomeObject();
so1=list.get(i);
spm=so1.getIpm("ipm");
sgg=so1.getIgg("igg");
slh=so1.getIlh("ilh");
}
//提示The method getIpm() in the type IndexSomeObject is not applicable for the arguments (String)
String spm="";
String sgg="";
String slh="";
List<IndexSomeObject> list = new ArrayList<IndexSomeObject>();
list=(List<IndexSomeObject>)request.getSession().getAttribute("someListi");
for(int i=0;i<list.size();i++){
IndexSomeObject so1 =new IndexSomeObject();
so1=list.get(i);
spm=so1.getIpm("ipm");
sgg=so1.getIgg("igg");
slh=so1.getIlh("ilh");
}
get方法没有参数~~~你直接可以
spm=so1.getIpm();
sgg=so1.getIgg();
slh=so1.getIlh();
你可以去IndexSomeObject 方法里看看
看看那个方法有参数没???