请问在软件开发的struts框架中“模块”到底是什么东西?

来源:百度知道 编辑:UC知道 时间:2024/05/23 00:24:54
能不能说具体点?
比如像在ActionSevrlet类中的selectModule()方法,好像是选择一个合适的应用模块来处理当前请求。
这个模块到底是什么东西啊?怎么处理当前请求?

我们知道struts的配置文件是struts-config-*.xml。其中根元素是<struts-config>...</struts-config>

在web.xml文件中我们配置org.apache.struts.action.ActionServlet这个servlet。在服务器开启服务时会进行一些初始化的工作。其中重要的一份工作就是初始化ModuleConfig。ModuleConfig是和struts配置文件相对应的,说的具体点是和<struts-config>对应的。一个配置文件对应一个moduleconfig。

下面是ModuleConfig的实现类ModuleConfigImpl类的一些变量。我们可以很明白的看出moduleconfig的作用

// 这个HashMap用来存储ActionConfig对象。
protected HashMap actionConfigs:
//HashMap用来存储DataSourceConfig对象。
protected HashMap dataSources
//这个HashMap用来存储ExceptionConfig对象。
protected HashMap exceptions
//这个HashMap用来存储FormBeanConfig对象。
protected HashMap formBeans
//这个HashMap用来存储ForwardConfig对象。
protected HashMap forwards
//这个HashMap用来存储MessageResourcesConfig对象。
protected HashMap messageResources
//这个HashMap用来存储PlugInConfig对象。
protected ArrayList plugIns
//ControllerConfig类
protected ControllerConfig controllerConfig
//标志这个Module