[接3楼]
之前有点言重了……答案如下:可以。得在web.xml配置初始参数config    <filter>
        <filter-name>struts2</filter-name>
        <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
        <init-param>
         <param-name>config</param-name>
         <param-value>struts-default.xml,struts-plugin.xml,/WEB-INF/struts.xml</param-value>
        </init-param>
    </filter>    <filter-mapping>
        <filter-name>struts2</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>以上配置方式已通过测试,成功!

解决方案 »

  1.   

    兄弟们啊,我知道啊,但是到底能不能100%确定struts.xml能放在web-info下面!
    没用过,没有发言权!
      

  2.   

    可以通过struts2 过滤器的xml参数设置,就象四楼说的一样。下面是struts 2读取config参数的源代码:    private void init_TraditionalXmlConfigurations() {
            String configPaths = initParams.get("config");
            if (configPaths == null) {
                configPaths = DEFAULT_CONFIGURATION_PATHS;
            }
            String[] files = configPaths.split("\\s*[,]\\s*");
            for (String file : files) {
                if (file.endsWith(".xml")) {
                    if ("xwork.xml".equals(file)) {
                        configurationManager.addConfigurationProvider(new XmlConfigurationProvider(file, false));
                    } else {
                        configurationManager.addConfigurationProvider(new StrutsXmlConfigurationProvider(file, false, servletContext));
                    }
                } else {
                    throw new IllegalArgumentException("Invalid configuration file name");
                }
            }
        }该代码在Dispatcher类中(Dispatcher.java)
    从上面的代码可以看出,Struts 2的config参数所设置的文件必须以.xml结尾,如果是其他类型的文件,如.txt,会抛出异常(就算文件里是xml格式也不行,struts 2是检查文件扩展名的)。而如果是.xml结尾文件,则会将会考虑其他的,如struts.xml