How does Struts create an action bean?

北城余情 提交于 2019-12-11 20:58:00

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/25842888/how-does-struts-create-an-action-bean

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!