struts2导入多个xml引入报错<include>

struts.xml

Xml代码   收藏代码
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <!-- 指定Struts 2配置文件的DTD信息 -->  
  3. <!DOCTYPE struts PUBLIC  
  4.     "-//Apache Software Foundation//DTD Struts Configuration 2.1.7//EN"  
  5.     "http://struts.apache.org/dtds/struts-2.3.dtd">  
  6. <!-- Struts 2配置文件的根元素 -->  
  7. <struts>  
  8.     <!-- struts2 默认配置文件,必须加进来 有这里看出,当前文件的路径是跟路径下classes路径,所以其他的文件要从classes这个路径开始找 -->  
  9.     <include file="struts-plugin.xml" />  
  10.     <include file="struts-default.xml" />  
  11.     <!-- 自己添加的配置文件 -->  
  12.     <include file="../struts2/struts_user.xml" />  
  13.     <include file="../struts2/struts_sign.xml" />  
  14. </struts>  



struts_user.xml

Xml代码   收藏代码
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <!-- 指定Struts 2配置文件的DTD信息 -->  
  3. <!DOCTYPE struts PUBLIC  
  4.     "-//Apache Software Foundation//DTD Struts Configuration 2.1.7//EN"  
  5.     "http://struts.apache.org/dtds/struts-2.3.dtd">  
  6. <!-- Struts 2配置文件的根元素 -->  
  7. <struts>  
  8.     <!-- 配置了系列常量 -->  
  9.     <constant name="struts.i18n.encoding" value="UTF-8" />  
  10.     <constant name="struts.devMode" value="true" />  
  11.   
  12.     <package name="Aberic" extends="struts-default">  
  13.         <!-- 定义处理用户请求的Action -->  
  14.         <action name="login" class="loginAction">  
  15.             <!-- 为两个逻辑视图配置视图页面 -->  
  16.             <result name="error">/error.jsp</result>  
  17.             <result name="success">/admin/admin.jsp</result>  
  18.             <interceptor-ref name="sessionstack" />  
  19.         </action>  
  20.     </package>  
  21. </struts>  



struts_sign.xml

Xml代码   收藏代码
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <!-- 指定Struts 2配置文件的DTD信息 -->  
  3. <!DOCTYPE struts PUBLIC  
  4.     "-//Apache Software Foundation//DTD Struts Configuration 2.1.7//EN"  
  5.     "http://struts.apache.org/dtds/struts-2.3.dtd">  
  6. <!-- Struts 2配置文件的根元素 -->  
  7. <struts>  
  8.     <!-- 配置了系列常量 -->  
  9.     <constant name="struts.i18n.encoding" value="UTF-8" />  
  10.     <constant name="struts.devMode" value="true" />  
  11.   
  12.     <package name="Aberic" extends="struts-default">  
  13.         <!-- 定义处理用户请求的Action -->  
  14.         <action name="sign" class="PhoneSignAction">  
  15.             <!-- 因为仅提供手机签到,故不配置任何视图 -->  
  16.             <result type="stream">  
  17.                 <param name="contentType">text/html</param>  
  18.                 <param name="inputName">inputStream</param>  
  19.             </result>  
  20.         </action>  
  21.     </package>  
  22. </struts>  



web.xml

Xml代码   收藏代码
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">  
  3.   <servlet>  
  4.     <servlet-name>proxoolServletConfigurator</servlet-name>  
  5.     <servlet-class>  
  6.            org.logicalcobwebs.proxool.configuration.ServletConfigurator  
  7.         </servlet-class>  
  8.     <init-param>  
  9.       <param-name>xmlFile</param-name>  
  10.       <param-value>WEB-INF/proxool.xml</param-value>  
  11.     </init-param>  
  12.     <load-on-startup>1</load-on-startup>  
  13.   </servlet>  
  14.   <context-param>  
  15.     <param-name>log4jConfigLocation</param-name>  
  16.     <param-value>/WEB-INF/log4j.properties</param-value>  
  17.   </context-param>  
  18.   <context-param>  
  19.     <param-name>log4jRefreshInterval</param-name>  
  20.     <param-value>60000</param-value>  
  21.   </context-param>  
  22.   <listener>  
  23.     <listener-class>    
  24.             org.springframework.web.util.Log4jConfigListener    
  25.         </listener-class>  
  26.   </listener>  
  27.   <context-param>  
  28.     <param-name>contextConfigLocation</param-name>  
  29.     <param-value>/WEB-INF/spring/applicationContext.xml</param-value>  
  30.   </context-param>  
  31.   <listener>  
  32.     <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>  
  33.   </listener>  
  34.   <filter>  
  35.     <filter-name>struts2</filter-name>  
  36.     <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>  
  37.     <init-param>  
  38.       <param-name>config</param-name>  
  39.       <param-value>struts-default.xml,struts-plugin.xml,../struts2/struts.xml</param-value>  
  40.     </init-param>  
  41.   </filter>  
  42.   <filter-mapping>  
  43.     <filter-name>struts2</filter-name>  
  44.     <url-pattern>/*</url-pattern>  
  45.   </filter-mapping>  
  46.   <session-config>  
  47.     <session-timeout>30</session-timeout>  
  48.   </session-config>  
  49.   <welcome-file-list>  
  50.     <welcome-file>index.jsp</welcome-file>  
  51.   </welcome-file-list>  
  52. </web-app>  



因为我配的有spring,所以action中class没有指定类而是交给spring管理了
现在有一个奇怪的问题就是当我把../struts2/struts_user.xml先include进去的时候,就能够成功加载进去,登陆操作无误
当我把../struts2/struts_sign.xml放在../struts2/struts_user.xml上面的时候,就成了签到成功,但登陆却提示找不到action了
总之就是只能有一个生效,这个问题纠结了好几天了

 

 

采纳的答案

题主好。

看了一下配置文件,发现两个配置文件的packageName都是相同的,建议修改成不同的名称试试

转载于:https://www.cnblogs.com/sharpest/p/6031010.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值