String temp = "1";
session.setAttribute("temp",temp);
String temp1=(String)session.getAttribute("temp");
temp1="2";
String temp3=(String)session.getAttribute("temp");\
temp3=? 其实我想问问getAttribute返回的引用还是一个拷贝,我这样更改temp1的值会更新temp的值吗,如果不会那要怎么做才能更新呢?再set一回?那会不会在session中又产生另一个对象呢。
session.setAttribute("temp",temp);
String temp1=(String)session.getAttribute("temp");
temp1="2";
String temp3=(String)session.getAttribute("temp");\
temp3=? 其实我想问问getAttribute返回的引用还是一个拷贝,我这样更改temp1的值会更新temp的值吗,如果不会那要怎么做才能更新呢?再set一回?那会不会在session中又产生另一个对象呢。
session貌似没想过,如果楼主找到答案,应该把答案写出来
这才叫分享..
不然你这不光叫别人帮你回答问题?自己确根本不帮助别人
这句只改变了temp1的引用
eg:
id ...
1 ...
2 ...
3 ...
String s=rs.getString("id");
session.setAttribute("getid",s);
那么 session.getAttribute("getid")的值应该是多少?
temp的值确实没有变,原因的话我觉得这个应该是比较合理的。