把struts.xml放在哪里?

把struts.xml放在哪里?

我迟到了,我们可以在web应用程序的类路径中的任何目录中配置struts.xml,但如果web.xml文件位于"/com/resources/“目录中,则使用web.xml中过滤器配置的"config”init参数提供位置,如下所示。

代码语言:javascript运行复制

action

org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter

config

struts-default.xml,struts-plugin.xml,/com/resources/struts.xml

如果我们不提供一个配置init参数,默认情况下struts2采用3个值"struts-default.xml,struts-plugin.xml,struts.xml",您可以看到下面的struts2 Dispatcher类代码,它将这3个文件配置到配置管理器。

代码语言:javascript运行复制String configPaths = (String)this.initParams.get("config");

if (configPaths == null) {

configPaths = "struts-default.xml,struts-plugin.xml,struts.xml";

}

String[] files = configPaths.split("\\s*[,]\\s*");

for (String file : files)

if (file.endsWith(".xml")) {

if ("xwork.xml".equals(file))

this.configurationManager.addContainerProvider(createXmlConfigurationProvider(file, false));

else

this.configurationManager.addContainerProvider(createStrutsXmlConfigurationProvider(file, false, this.servletContext));

}

相关推荐

能克制苏烈的英雄只有这四个,你知道都有谁吗
365bet体育投注地址

能克制苏烈的英雄只有这四个,你知道都有谁吗

📅 06-29 👁️ 578
王者荣耀怎么索要皮肤 新版皮肤索要功能解读
365bet体育投注地址

王者荣耀怎么索要皮肤 新版皮肤索要功能解读

📅 06-28 👁️ 7364
漫威漫画角色列表
365bet体育投注地址

漫威漫画角色列表

📅 06-30 👁️ 3535
最右版本大全
365bet开户网站

最右版本大全

📅 06-29 👁️ 9003