关于session.getValueNames()的一个问题

来源:互联网 发布:java核心技术 下载 编辑:程序博客网 时间:2024/06/03 21:23

sessioni对象
(0)

<%         session.setAttribute("username", "admin");        session.setAttribute("password", "123456");        session.setAttribute("age", “man");                         String names[] = session.getValueNames();    for(int i=0;i<=names.length;i++)   {    out.println(names[i]+"&nbsp;&nbsp;");//不知道为什么要倒着输出      }%>
  • 输出结果为:password age username

(1)

<%         session.setAttribute("username", "admin");        session.setAttribute("password", "123456");        session.setAttribute("age", “man");                         String names[] = session.getValueNames();    for(int i=names.length-1;i>=0;i--)   {    out.println(names[i]+"&nbsp;&nbsp;");//不知道为什么要倒着输出      }%>
  • 输出结果为:username age password

    原因不明!

0 0
原创粉丝点击