我将使用struts2-spring-plugin集成struts2和spring,但在我添加依赖struts2-spring-plugin后, 我得到了这个
这是错误
[2016-12-02 11:48:42,010] Artifact Gradle : com.example : Struts2-Plugin-1.0-SNAPSHOT.war (exploded): Artifact is being deployed, please wait...
02-Dec-2016 11:48:44.260 信息 [RMI TCP Connection(2)-127.0.0.1] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
02-Dec-2016 11:48:44.354 信息 [RMI TCP Connection(2)-127.0.0.1] org.springframework.web.context.ContextLoader.initWebApplicationContext Root WebApplicationContext: initialization started
02-Dec-2016 11:48:44.557 信息 [RMI TCP Connection(2)-127.0.0.1] org.springframework.web.context.support.XmlWebApplicationContext.prepareRefresh Refreshing Root WebApplicationContext: startup date [Fri Dec 02 11:48:44 CST 2016]; root of context hierarchy
02-Dec-2016 11:48:44.651 信息 [RMI TCP Connection(2)-127.0.0.1] org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions Loading XML bean definitions from class path resource [applicationContext.xml]
02-Dec-2016 11:48:44.948 信息 [RMI TCP Connection(2)-127.0.0.1] org.springframework.web.context.ContextLoader.initWebApplicationContext Root WebApplicationContext: initialization completed in 594 ms
ERROR StatusLogger Log4j2 could not find a logging implementation. Please add log4j-core to the classpath. Using SimpleLogger to log to the console...
02-Dec-2016 11:48:46.151 严重 [RMI TCP Connection(2)-127.0.0.1] org.apache.catalina.core.StandardContext.startInternal One or more Filters failed to start. Full details will be found in the appropriate container log file
02-Dec-2016 11:48:46.151 严重 [RMI TCP Connection(2)-127.0.0.1] org.apache.catalina.core.StandardContext.startInternal Context [] startup failed due to previous errors
02-Dec-2016 11:48:46.151 信息 [RMI TCP Connection(2)-127.0.0.1] org.springframework.web.context.support.XmlWebApplicationContext.doClose Closing Root WebApplicationContext: startup date [Fri Dec 02 11:48:44 CST 2016]; root of context hierarchy
[2016-12-02 11:48:46,182] Artifact Gradle : com.example : Struts2-Plugin-1.0-SNAPSHOT.war (exploded): Error during artifact deployment. See server log for details.
这是build.gradle
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.11'
compile group: 'org.apache.struts', name: 'struts2-core', version: '2.5'
//compile group: 'org.apache.struts', name: 'struts2-spring-plugin', version: '2.5'
compile group: 'org.springframework', name: 'spring-jdbc', version: '4.3.3.RELEASE'
compile 'org.springframework:spring-context:4.3.4.RELEASE'
// https://mvnrepository.com/artifact/org.springframework/spring-web
compile group: 'org.springframework', name: 'spring-web', version: '4.2.5.RELEASE'
compile group: 'javax.servlet',name: 'jsp-api',version: '2.0'
compile 'javax.servlet:javax.servlet-api:3.0.1'
}
这是web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>
<filter>
<filter-name>struts</filter-name>
<!-- here show that filter should have a mapping-->
<filter-class>
org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
</web-app>