Struts的重中之重--对象工厂
2016-08-07 23:03
190 查看
一、什么是对象工厂?
Struts2中引了xwork中的对象工厂、它的作用就是把配置文件中的action、result、package对象的创建。它创建各类的对象,所以说是对象工厂。
二、对象工厂有什么方法?在struts中结构是怎么样的?
![](https://img-blog.csdn.net/20160807224330746)
在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>
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>
相关文章推荐
- 静态工厂方法创建对象
- Javascript之创建对象(工厂模式与构造函数模式)
- 创建对象与使用对象——谈谈工厂的作用
- struts2下velocity做视图如何访问request,session等内置对象,如:原来webwork的$req
- spring中通过静态工厂方法获取bean实例化对象
- Abstract Factory (对象)--抽象工厂,产品对象家族。
- struts用对象封装传入的参数
- 工厂对象模式简介
- 用 Flask 来写个轻博客 (18) — 使用工厂模式来生成应用对象
- JS高级 - 面向对象1(this,Object ,工厂方式,new )
- 创建和销毁对象--考虑用静态工厂方法代替构造函数
- 1.3 Factory Method(工厂方法) -- 对象创建型模式
- Struts ActionServlet控制器对象
- Symbian常用设计模式之可伸缩对象工厂
- 工厂模式:封装对象的创建(三、抽象工厂)
- JS面向对象基础讲解(工厂模式、构造函数模式、原型模式、混合模式、动态原型模式)
- JavaScript构造函数及原型对象 使用Object或对象字面量创建对象 工厂模式创建对象 构造函数模式创建对象 原型模式创建对象 构造与原型混合模式创建对象
- 用flask开发个人博客(27)—— 利用程序工厂函数创建Flask程序对象并注册蓝本
- spring 框架最基本的功能就是充当创建对象的工厂
- 第七章 泛化对象工厂(Object Factories) (这章完全不同于《C++设计新思维》中对象工厂)