Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

struts 2 question

 
ben oliver
Ranch Hand
Posts: 375
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It shows that struts 2 put object(s) in its value stack. I am wondering what are put into the "object" part of value stack ? For example, if I have an action like

public class HelloStruts {

public static final String MESSAGE = "Struts is up and running ...";

public String execute() throws Exception {
setMessage(MESSAGE);
return "success";
}

private String message;

public void setMessage(String message){
this.message = message;
}

public String getMessage() {
return message;
}
}

Is the "HelloStruts" obj put in the value stack' object list ? Do I have to explicitly do something to add it to value stack ? If I have several pages, from 1st Action to 2nd Action, to 3rd Action, etc, are all of them automatically all saved in the value stack's object list ? or only the last Action is saved in the value stack's object list ?
 
Nishan Patel
Ranch Hand
Posts: 689
Eclipse IDE Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

hi,

yes, only last action value you can get and all action variable are store at OGNL value stack.

and you don't need to do explicitly. If you want to your action class variable to after three or four iteration of your action then you have to put it to your session.

for more information see Struts2 + OGNL value stack.

http://struts.apache.org/2.0.14/docs/ognl-basics.html



 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic