我们在做JSP页面的时候有时会把某个对象放到request当中,比如
有一个Student对象放在request中
Student s=new Student();
request.setAttribute("stu",s);然后我们在另一个页面把它取出来
Student ss=(Student)request.getAttribute("stu");这时要用到强制转换(Student),但我想动态的获取它,
我知道要获取Student对象可以用:request.getAttribute("stu").getClass();
但这时它还只是个Object,
我用这段话代替(Student)的时候却不行,
(request.getAttribute("stu").getClass())request.getAttribute("stu");请问我要怎么写????????
有一个Student对象放在request中
Student s=new Student();
request.setAttribute("stu",s);然后我们在另一个页面把它取出来
Student ss=(Student)request.getAttribute("stu");这时要用到强制转换(Student),但我想动态的获取它,
我知道要获取Student对象可以用:request.getAttribute("stu").getClass();
但这时它还只是个Object,
我用这段话代替(Student)的时候却不行,
(request.getAttribute("stu").getClass())request.getAttribute("stu");请问我要怎么写????????
比如说Person一个对象,那个页面也能获得到
(request.getAttribute("stu").getClass().getName())request.getAttribute("stu");
request.getAttribute("stu").getClass().getName()
是个String类型