第一种
ActionServlet.javapublic void init()
        throws ServletException
    {
        initInternal();
        initOther();
        initServlet();
        getServletContext().setAttribute("org.apache.struts.action.ACTION_SERVLET", this);
        ModuleConfig moduleConfig = initModuleConfig("", config);//★★★这里
        initModuleMessageResources(moduleConfig);
        initModuleDataSources(moduleConfig);
        initModulePlugIns(moduleConfig);
        moduleConfig.freeze();
        for(Enumeration names = getServletConfig().getInitParameterNames(); names.hasMoreElements();)
        {
            String name = (String)names.nextElement();
            if(name.startsWith("config/"))
            {
                String prefix = name.substring(6);
                moduleConfig = initModuleConfig(prefix, getServletConfig().getInitParameter(name));
                initModuleMessageResources(moduleConfig);
                initModuleDataSources(moduleConfig);
                initModulePlugIns(moduleConfig);
                moduleConfig.freeze();
            }
        }        destroyConfigDigester();
    }

解决方案 »

  1.   

    我独排众议,我认为第一种也有其存在的价值.
    第二种是解决了命名冲突的问题,不过每个模块都产生了相对路径的问题,比如说有一些公众的image或 js文件夹,程序员容易产生疑惑.另外,在全局异常定义上,如果使用第二种,我印象中好象无法实现,在一个根xml中定制异常,全部子模块都默认捕获.
      

  2.   

    如果你的团队菜鸟居多,使用第一种配置方式不容易扰乱他们既有的开发思路,我认为命名问题在开发中很容易约束,只要文件分开,减少check out冲突就好.
      

  3.   

    感谢各位。
    我以前用的是第二种,所以对此有好感。对于_chage(_chage) 同学说的问题确实存在,不过全局异常我们倒是没用到。我恰恰是喜欢她的相对路径和模块独立。第一种是团队老大定好的,这种也知道他实际还是一个文件。_chage(_chage) 同学你说的命名冲突是不是指的是path和forward?大家继续讨论。分不够在开贴送分,多的是。
      

  4.   

    命名冲突很好理解呀,例如模块间的action名不能重复。
    第二种“更容易控制”,我倒不觉得。我指的异常处理,请参见我的blog中:
    http://blog.csdn.net/_chage/archive/2004/12/17/219600.aspx