struts-config文件路径问题
程序员文章站
2022-03-05 13:22:06
...
一 介绍
struts-config文件路径,不一定非要放在/WEB-INF中,可以自己放。
二 修改方法
例如:struts-config放置路径如下截图
配置方法
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; version="2.5" xsi:schemaLocation="http://java.sun.com/xml/ns/javaeehttp://java.sun.com/xml/ns/javaee/web-app_2_5.xsd";>
<display-name />
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<!-- 配置struts-config.xml -->
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/config/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>3</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>3</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
</servlet>
<filter>
<filter-name>Myfilter1</filter-name>
<filter-class>com.cakin.filters.Myfilter1</filter-class>
</filter>
<filter-mapping>
<filter-name>Myfilter1</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
三 测试结果
四 怎样配置多个struts-config文件
在web.xml文件可以配置
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/config/struts-config.xml,/WEB-INF/config/struts-config-2.xml</param-value>
</init-param>
<init-param>