关于session.getValueNames()的一个问题
(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

    原因不明!

相关文章:

  • 2022-02-01
  • 2021-09-18
  • 2021-04-22
  • 2022-03-07
  • 2021-11-09
  • 2021-04-26
  • 2021-07-11
  • 2021-04-30
猜你喜欢
  • 2021-11-10
  • 2021-12-14
  • 2021-06-04
  • 2021-12-06
  • 2021-10-28
  • 2021-09-09
相关资源
相似解决方案