3

When would be the bean tag used in struts.xml configuration file using Struts 2? What is difference between action class properties and bean tag in Struts 2 configuration file struts.xml?

informatik01
  • 16,038
  • 10
  • 74
  • 104
user1357722
  • 7,088
  • 13
  • 34
  • 43

1 Answers1

0

Some places have strict separation of work or for what ever reason you can edit the view (JSP) but not the actions source.

In this case the bean tag becomes most useful (otherwise I agree it isn't particularly attractive). It is generally easiest to produce what is needed for the view within the action and also process that data such that it is readily displayable. As such there is not generally much need for append, generator, merge tags either... but once again if you consider the content people separate from the backend people these tags would be used more often.

In theory it is possible to use the bean tag to access things like singletons for counters and such, but if the view is acquiring resources in this way it is kind of a component way of thinking(as opposed to action based thinking). This is also why the action tag's use isn't particularly favored either. If you need it, the action class should be the main one responsible for getting it (or interceptors, but certainly not the view) at least following action based thinking.

Quaternion
  • 10,380
  • 6
  • 51
  • 102