您的位置:首页 > 编程语言 > Java开发

Struts的重中之重--对象工厂

2016-08-07 23:03 190 查看
一、什么是对象工厂?

       Struts2中引了xwork中的对象工厂、它的作用就是把配置文件中的action、result、package对象的创建。它创建各类的对象,所以说是对象工厂。

二、对象工厂有什么方法?在struts中结构是怎么样的?

       


          在struts2.0中:

          <bean class="com.opensymphony.xwork2.ObjectFactory" name="struts"/>
<bean type="com.opensymphony.xwork2.factory.ResultFactory" name="struts" class="org.apache.struts2.factory.StrutsResultFactory" />
<bean type="com.opensymphony.xwork2.factory.ActionFactory" name="struts" class="com.opensymphony.xwork2.factory.DefaultActionFactory" />
<bean type="com.opensymphony.xwork2.factory.ConverterFactory" name="struts" class="com.opensymphony.xwork2.factory.DefaultConverterFactory" />
<bean type="com.opensymphony.xwork2.factory.InterceptorFactory" name="struts" class="com.opensymphony.xwork2.factory.DefaultInterceptorFactory" />
<bean type="com.opensymphony.xwork2.factory.ValidatorFactory" name="struts" class="com.opensymphony.xwork2.factory.DefaultValidatorFactory" />
<bean type="com.opensymphony.xwork2.factory.UnknownHandlerFactory" name="struts" class="com.opensymphony.xwork2.factory.DefaultUnknownHandlerFactory" />

三、对象工厂中对象工厂是怎么配置的。

   1.在property文件设置常量属性对象工厂

    2.在struts.xml配置文件中配置把struts-default.xml中的objectFactory覆盖。

四、spring-struts-plugin是如何把对象加载交给spring容器的

   <struts>
<bean type="com.opensymphony.xwork2.ObjectFactory" name="spring" class="org.apache.struts2.spring.StrutsSpringObjectFactory" />

<!-- Make the Spring object factory the automatic default -->
<constant name="struts.objectFactory" value="spring" />

<constant name="struts.class.reloading.watchList" value="" />
<constant name="struts.class.reloading.acceptClasses" value="" />
<constant name="struts.class.reloading.reloadConfig" value="false" />

<package name="spring-default">
<interceptors>
<interceptor name="autowiring" class="com.opensymphony.xwork2.spring.interceptor.ActionAutowiringInterceptor"/>
</interceptors>
</package>
</struts>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  Struts