1

In Struts2, after using ModelDrivernInterceptor, the data is located in a model object,

And the model is been pushed to the ValueStack. then, after this.

How to access the Action's property?

Roman C
  • 49,761
  • 33
  • 66
  • 176
lovespring
  • 19,051
  • 42
  • 103
  • 153

2 Answers2

1

Access action properties as usual if you don't have the same property's names in the model and in the action classes. If you have the same names, you can only access action properties via accessing a value stack directly by the index, like in this question and answer: Passing parameters to action through ModelDriven in Struts 2.3.16.

Community
  • 1
  • 1
Roman C
  • 49,761
  • 33
  • 66
  • 176
  • will the action still be pushed to the ValueStack? I read the doc, says, the Model object will INSTAED the action object to be put into the valuestack, is it ture? – lovespring May 01 '14 at 20:20
  • Model is pushed by the interceptor, after the struts create the value stack and push an action instance onto it. – Roman C May 01 '14 at 20:27
0

Use #action.someProperty.

Using the stack index is fragile, e.g., if you change your JSP you may introduce stack depth, etc.

Dave Newton
  • 158,873
  • 26
  • 254
  • 302