struts2 ValueStack的set方法与setValue方法的区别 博客分类: Java Web struts2ValueStacksetsetvalue区别
程序员文章站
2024-02-24 18:54:04
...
ActionContext.getContext().getValueStack().setValue("myname22", "ttt");
ActionContext.getContext().getValueStack().set("myname22", "ttt");
String myname2=(String)ServletActionContext.getContext().getValueStack().findValue("myname22");
package example; import org.apache.struts2.ServletActionContext; import com.opensymphony.xwork2.ActionContext; import com.opensymphony.xwork2.ActionSupport; public class GetValueAction extends ActionSupport { private static final long serialVersionUID = 4865100826143278474L; private String myname=null; // private String myname22; @Override public String execute() throws Exception { ActionContext.getContext().getValueStack().set("myname22", "ttt"); String myname2=(String)ServletActionContext.getContext().getValueStack().findValue("myname22"); // System.out.println("myname2: "+this.myname); return super.execute(); } public String getMyname() { return myname; } public void setMyname(String myname) { this.myname = myname; } // public String getMyname22() { // return myname22; // } // // public void setMyname22(String myname22) { // System.out.println("abc:"+myname22); // this.myname22 = myname22; // } // public String getMyname22() { // return myname22; // } }