Struts如何创建一个动作bean? [英] How does Struts create an action bean?

查看:85
本文介绍了Struts如何创建一个动作bean?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Struts2.x,并且我知道Struts根据请求在操作中创建声明的Bean对象,以便该操作可以使用它.我一直在研究以了解Struts在内部使用哪些拦截器/类来创建bean对象.我试图了解内部用于创建Bean对象的逻辑.它是否使用PropertyUtils或其他方式填充bean的属性?任何建议或阅读指南将对您有所帮助.

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.

推荐答案

Struts内部使用ObjectFactory来构建配置定义的所有对象.查看有关 ObjectFactory 的更多信息docs或 Struts 2请求流程.

Internally Struts uses the ObjectFactory to build all objects defined by the configuration. See more about ObjectFactory docs or The Struts 2 Request Flow.

使用 params 拦截器填充某些bean时默认情况下,将在 OGNL 的帮助下创建对象.它也是可配置的.

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未被Struts2内核使用,但是如果插件需要commons-beanutils包,则可以被插件使用.

PropertyUtils isn't used by the Struts2 core, but could be used by plugins if they need a commons-beanutils package.

这篇关于Struts如何创建一个动作bean?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆