Struts2中的ValueStack
<%
Enumeration em = request.getAttributeNames();
while(em.hasMoreElements()){
Object obj = em.nextElement();
if(obj.equals("struts.valueStack")){
ValueStack vs = (ValueStack)request.getAttribute("struts.valueStack");
System.out.println(vs.findValue("username"));
System.out.println(vs.findValue("password"));
System.out.println(vs.findValue("[0].username"));
System.out.println(vs.findValue("[0].password"));
vs.toString();
}
}
%>
<%
Enumeration em = request.getAttributeNames();
while(em.hasMoreElements()){
Object obj = em.nextElement();
if(obj.equals("struts.valueStack")){
ValueStack vs = (ValueStack)request.getAttribute("struts.valueStack");
System.out.println(vs.findValue("username"));
System.out.println(vs.findValue("password"));
System.out.println(vs.findValue("[0].username"));
System.out.println(vs.findValue("[0].password"));
vs.toString();
}
}
%>
哈哈,原来Struts2在视图里是这样子拿到值的呀
本文介绍了如何在Struts2框架中通过ValueStack从请求中获取值。演示了使用findValue方法来检索username和password等属性的过程。
1万+

被折叠的 条评论
为什么被折叠?



