I use Struts2.x and I know that Struts creates the declared bean objects in the action based on the request so that it is available to the action. I have been researching to understand which interceptors/classes does Struts use internally to create the bean object. I am trying to understand the logic that is used internally for creation of the bean objects. Does it use PropertyUtils
to populate properties for the beans or some other way? Any suggestion or pointers for reading will be helpful.
Asked
Active
Viewed 738 times
0
1 Answers
0
Internally Struts uses the ObjectFactory
to build all objects defined by the configuration. See more about ObjectFactory
docs or The Struts 2 Request Flow.
When you populate some bean using params
interceptor it will by default create objects if they not exist with the help of OGNL. It's also configurable.
PropertyUtils
isn't used by the Struts2 core, but could be used by plugins if they need a commons-beanutils
package.

Roman C
- 49,761
- 33
- 66
- 176
-
I see that [ObjectFactory](http://grepcode.com/file/repo1.maven.org/maven2/com.opensymphony/xwork/2.1.3/com/opensymphony/xwork2/ObjectFactory.java/) has a method public Object buildBean(Class,Map
), but this just returns a new Instance of the class. The [ParametersInterceptor](http://struts.apache.org/release/2.3.x/docs/parameters-interceptor.html) says that it sets action.setModelClass() based on the properties of action and also pushes the accepted params to valueStack, but I am still searching where the values from the Map are set into the created object. – Manny Sep 16 '14 at 11:32