当前位置: 技术问答>java相关
session对象能不能传数组?
来源: 互联网 发布时间:2015-11-19
本文导语: session对象能不能传数组? String[] a = {"1","2","3"}; session.putAttribute("test",a); String[] b = new String[3]; session.getAttribute("test",b); 以上语法有问题吗? | 可以,取:String [] b = (String[])session.getAttr...
session对象能不能传数组?
String[] a = {"1","2","3"};
session.putAttribute("test",a);
String[] b = new String[3];
session.getAttribute("test",b);
以上语法有问题吗?
String[] a = {"1","2","3"};
session.putAttribute("test",a);
String[] b = new String[3];
session.getAttribute("test",b);
以上语法有问题吗?
|
可以,取:String [] b = (String[])session.getAttribute("test");
|
呵呵,当然可以传了。
|
String[] b = (String[])session.getAttribute("test");
/**
我没试过
*/
/**
我没试过
*/
|
API如是说到:
HttpSession
public void setAttribute(java.lang.String name,
java.lang.Object value)Binds an object to this session, using the name specified. If an object of the same name is already bound to the session, the object is replaced.
After this method executes, and if the object implements HttpSessionBindingListener, the container calls HttpSessionBindingListener.valueBound.
Parameters:
name - the name to which the object is bound; cannot be null
value - the object to be bound; cannot be null
由此看来是不行,他需要的对象是一个OBJECT的,不是String[]的.
HttpSession
public void setAttribute(java.lang.String name,
java.lang.Object value)Binds an object to this session, using the name specified. If an object of the same name is already bound to the session, the object is replaced.
After this method executes, and if the object implements HttpSessionBindingListener, the container calls HttpSessionBindingListener.valueBound.
Parameters:
name - the name to which the object is bound; cannot be null
value - the object to be bound; cannot be null
由此看来是不行,他需要的对象是一个OBJECT的,不是String[]的.
|
java数组就是一个object
|
可以,没有一点问题
|
对,可以传的,我弄错了.
|
可以传
您可能感兴趣的文章:
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。