늦어서 웹 응용 프로그램의 클래스 경로에있는 모든 디렉토리에서 struts.xml을 구성 할 수 있지만 필터의 "config"초기화 매개 변수를 사용하여 위치를 제공 할 수 있습니다 내 struts.xml 파일이 "/ com/resources /"디렉토리에있는 경우 아래의 web.xml의 구성을 참조하십시오.
<filter>
<filter-name>action</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
<init-param>
<param-name>config</param-name>
<param-value>struts-default.xml,struts-plugin.xml,/com/resources/struts.xml</param-value>
</init-param>
</filter>
기본값은 3 개 값을 사용하여 우리는 설정 초기화 파라미터 struts2를 제공하지 않는 경우 "스트럿-default.xml에, struts.xml-plugin.xml에 스트럿", 아래의 struts2 디스패처 클래스 코드를 볼 수 있습니다 이 파일은 구성 관리자에게이 3 개의 파일을 구성합니다.
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));
}
C :! \ 사용자 342,008 \ 바탕 화면 \ strus-structure.jpg 그렇게하는 동안 나는 404 오류를 받고 있어요 – jcrshankar