struts.xml
- <?xml version="1.0" encoding="UTF-8"?>
- <!-- 指定Struts 2配置文件的DTD信息 -->
- <!DOCTYPE struts PUBLIC
- "-//Apache Software Foundation//DTD Struts Configuration 2.1.7//EN"
- "http://struts.apache.org/dtds/struts-2.3.dtd">
- <!-- Struts 2配置文件的根元素 -->
- <struts>
- <!-- struts2 默认配置文件,必须加进来 有这里看出,当前文件的路径是跟路径下classes路径,所以其他的文件要从classes这个路径开始找 -->
- <include file="struts-plugin.xml" />
- <include file="struts-default.xml" />
- <!-- 自己添加的配置文件 -->
- <include file="../struts2/struts_user.xml" />
- <include file="../struts2/struts_sign.xml" />
- </struts>
struts_user.xml
- <?xml version="1.0" encoding="UTF-8"?>
- <!-- 指定Struts 2配置文件的DTD信息 -->
- <!DOCTYPE struts PUBLIC
- "-//Apache Software Foundation//DTD Struts Configuration 2.1.7//EN"
- "http://struts.apache.org/dtds/struts-2.3.dtd">
- <!-- Struts 2配置文件的根元素 -->
- <struts>
- <!-- 配置了系列常量 -->
- <constant name="struts.i18n.encoding" value="UTF-8" />
- <constant name="struts.devMode" value="true" />
- <package name="Aberic" extends="struts-default">
- <!-- 定义处理用户请求的Action -->
- <action name="login" class="loginAction">
- <!-- 为两个逻辑视图配置视图页面 -->
- <result name="error">/error.jsp</result>
- <result name="success">/admin/admin.jsp</result>
- <interceptor-ref name="sessionstack" />
- </action>
- </package>
- </struts>
struts_sign.xml
- <?xml version="1.0" encoding="UTF-8"?>
- <!-- 指定Struts 2配置文件的DTD信息 -->
- <!DOCTYPE struts PUBLIC
- "-//Apache Software Foundation//DTD Struts Configuration 2.1.7//EN"
- "http://struts.apache.org/dtds/struts-2.3.dtd">
- <!-- Struts 2配置文件的根元素 -->
- <struts>
- <!-- 配置了系列常量 -->
- <constant name="struts.i18n.encoding" value="UTF-8" />
- <constant name="struts.devMode" value="true" />
- <package name="Aberic" extends="struts-default">
- <!-- 定义处理用户请求的Action -->
- <action name="sign" class="PhoneSignAction">
- <!-- 因为仅提供手机签到,故不配置任何视图 -->
- <result type="stream">
- <param name="contentType">text/html</param>
- <param name="inputName">inputStream</param>
- </result>
- </action>
- </package>
- </struts>
web.xml
- <?xml version="1.0" encoding="UTF-8"?>
- <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">
- <servlet>
- <servlet-name>proxoolServletConfigurator</servlet-name>
- <servlet-class>
- org.logicalcobwebs.proxool.configuration.ServletConfigurator
- </servlet-class>
- <init-param>
- <param-name>xmlFile</param-name>
- <param-value>WEB-INF/proxool.xml</param-value>
- </init-param>
- <load-on-startup>1</load-on-startup>
- </servlet>
- <context-param>
- <param-name>log4jConfigLocation</param-name>
- <param-value>/WEB-INF/log4j.properties</param-value>
- </context-param>
- <context-param>
- <param-name>log4jRefreshInterval</param-name>
- <param-value>60000</param-value>
- </context-param>
- <listener>
- <listener-class>
- org.springframework.web.util.Log4jConfigListener
- </listener-class>
- </listener>
- <context-param>
- <param-name>contextConfigLocation</param-name>
- <param-value>/WEB-INF/spring/applicationContext.xml</param-value>
- </context-param>
- <listener>
- <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
- </listener>
- <filter>
- <filter-name>struts2</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,../struts2/struts.xml</param-value>
- </init-param>
- </filter>
- <filter-mapping>
- <filter-name>struts2</filter-name>
- <url-pattern>/*</url-pattern>
- </filter-mapping>
- <session-config>
- <session-timeout>30</session-timeout>
- </session-config>
- <welcome-file-list>
- <welcome-file>index.jsp</welcome-file>
- </welcome-file-list>
- </web-app>
因为我配的有spring,所以action中class没有指定类而是交给spring管理了
现在有一个奇怪的问题就是当我把../struts2/struts_user.xml先include进去的时候,就能够成功加载进去,登陆操作无误
当我把../struts2/struts_sign.xml放在../struts2/struts_user.xml上面的时候,就成了签到成功,但登陆却提示找不到action了
总之就是只能有一个生效,这个问题纠结了好几天了
采纳的答案
题主好。
看了一下配置文件,发现两个配置文件的packageName都是相同的,建议修改成不同的名称试试