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" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 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">
<display-name>SS</display-name>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
在WEB-INF下新建applicationContext.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
</beans>
src下新建struts.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC "//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="default" namespace="/" extends="struts-default">
<action name="HelloWorld" class="com.ghl.HelloWorld">
<result name="success">/success.jsp</result>
</action>
</package>
<include file="user.xml"></include>
</struts>
src下新建com.ghl.HelloWorld.java:
package com.ghl;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.util.logging.Logger;
import com.opensymphony.xwork2.util.logging.LoggerFactory;
public class HelloWorld extends ActionSupport{
/**
*
*/
private static final long serialVersionUID = -6452565149473931988L;
Logger log = LoggerFactory.getLogger(HelloWorld.class);
@Override
public String execute() throws Exception {
log.info("execute");
return SUCCESS;
}
@Override
public void validate() {
log.info("validate");
}
}
部署在tomcat下,问题:
警告: Unable to load config class org.apache.struts2.jsf.FacesSetupInterceptor at interceptor - jar:file:/D:/ghl/apache-tomcat-6.0.20/wtpwebapps/SS/WEB-INF/lib/struts2-jsf-plugin-2.1.8.1.jar!/struts-plugin.xml:35:97 probably due to a missing jar, which might be fine if you never plan to use the jsfSetup interceptor
2010-6-10 14:14:21 com.opensymphony.xwork2.util.logging.commons.CommonsLogger error
严重: Actual exception
Could not load class org.apache.struts2.jsf.FacesSetupInterceptor. Perhaps it exists but certain dependencies are not available? - interceptor - jar:file:/D:/ghl/apache-tomcat-6.0.20/wtpwebapps/SS/WEB-INF/lib/struts2-jsf-plugin-2.1.8.1.jar!/struts-plugin.xml:35:97
at com.opensymphony.xwork2.ObjectFactory.buildInterceptor(ObjectFactory.java:202)
解决:
删除:struts2-jsf-plugin-2.1.8.1.jar
问题:
警告: Unable to load config class org.apache.struts2.portlet.interceptor.PortletAwareInterceptor at interceptor - jar:file:/D:/ghl/apache-tomcat-6.0.20/wtpwebapps/SS/WEB-INF/lib/struts2-portlet-plugin-2.1.8.1.jar!/struts-plugin.xml:48:114 probably due to a missing jar, which might be fine if you never plan to use the portletAware interceptor
2010-6-10 14:16:37 com.opensymphony.xwork2.util.logging.commons.CommonsLogger error
严重: Actual exception
Could not load class org.apache.struts2.portlet.interceptor.PortletAwareInterceptor. Perhaps it exists but certain dependencies are not available? - interceptor - jar:file:/D:/ghl/apache-tomcat-6.0.20/wtpwebapps/SS/WEB-INF/lib/struts2-portlet-plugin-2.1.8.1.jar!/struts-plugin.xml:48:114
at com.opensymphony.xwork2.ObjectFactory.buildInterceptor(ObjectFactory.java:202)
解决
删除:struts2-portlet-plugin-2.1.8.1.jar
问题:
严重: Dispatcher initialization failed
java.lang.NullPointerException
at org.apache.struts2.osgi.OsgiConfigurationProvider.init(OsgiConfigurationProvider.java:70)
解决:
删除:struts2-osgi-plugin-2.1.8.1.jar
问题:
严重: Dispatcher initialization failed
java.lang.RuntimeException: java.lang.RuntimeException: com.opensymphony.xwork2.inject.DependencyException: com.opensymphony.xwork2.inject.ContainerImpl$MissingDependencyException: No mapping found for dependency [type=java.lang.String, name='actionPackages'] in public void org.apache.struts2.config.ClasspathPackageProvider.setActionPackages(java.lang.String).
at com.opensymphony.xwork2.inject.ContainerBuilder$4.create(ContainerBuilder.java:132)
解决:
修改web.xml:
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
<init-param>
<param-name>actionPackages</param-name>
<param-value>com.ghl</param-value>
</init-param>
</filter>
问题:
警告: Could not find action or result
There is no Action mapped for namespace / and action name HelloWorld. - [unknown location]
at com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:178)
解决:
把 struts.xml文件放到WEB-INF/classes目录下
问题:
java.lang.NoSuchMethodException: com.ghl.HelloWorld.index()
java.lang.Class.getMethod(Unknown Source)
org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.getActionMethod(AnnotationValidationInterceptor.java:75)
解决:
HelloWorld.java中追加方法:
public String index(){
log.info("index");
return SUCCESS;
}
<?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" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 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">
<display-name>SS</display-name>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
在WEB-INF下新建applicationContext.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
</beans>
src下新建struts.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC "//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="default" namespace="/" extends="struts-default">
<action name="HelloWorld" class="com.ghl.HelloWorld">
<result name="success">/success.jsp</result>
</action>
</package>
<include file="user.xml"></include>
</struts>
src下新建com.ghl.HelloWorld.java:
package com.ghl;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.util.logging.Logger;
import com.opensymphony.xwork2.util.logging.LoggerFactory;
public class HelloWorld extends ActionSupport{
/**
*
*/
private static final long serialVersionUID = -6452565149473931988L;
Logger log = LoggerFactory.getLogger(HelloWorld.class);
@Override
public String execute() throws Exception {
log.info("execute");
return SUCCESS;
}
@Override
public void validate() {
log.info("validate");
}
}
部署在tomcat下,问题:
警告: Unable to load config class org.apache.struts2.jsf.FacesSetupInterceptor at interceptor - jar:file:/D:/ghl/apache-tomcat-6.0.20/wtpwebapps/SS/WEB-INF/lib/struts2-jsf-plugin-2.1.8.1.jar!/struts-plugin.xml:35:97 probably due to a missing jar, which might be fine if you never plan to use the jsfSetup interceptor
2010-6-10 14:14:21 com.opensymphony.xwork2.util.logging.commons.CommonsLogger error
严重: Actual exception
Could not load class org.apache.struts2.jsf.FacesSetupInterceptor. Perhaps it exists but certain dependencies are not available? - interceptor - jar:file:/D:/ghl/apache-tomcat-6.0.20/wtpwebapps/SS/WEB-INF/lib/struts2-jsf-plugin-2.1.8.1.jar!/struts-plugin.xml:35:97
at com.opensymphony.xwork2.ObjectFactory.buildInterceptor(ObjectFactory.java:202)
解决:
删除:struts2-jsf-plugin-2.1.8.1.jar
问题:
警告: Unable to load config class org.apache.struts2.portlet.interceptor.PortletAwareInterceptor at interceptor - jar:file:/D:/ghl/apache-tomcat-6.0.20/wtpwebapps/SS/WEB-INF/lib/struts2-portlet-plugin-2.1.8.1.jar!/struts-plugin.xml:48:114 probably due to a missing jar, which might be fine if you never plan to use the portletAware interceptor
2010-6-10 14:16:37 com.opensymphony.xwork2.util.logging.commons.CommonsLogger error
严重: Actual exception
Could not load class org.apache.struts2.portlet.interceptor.PortletAwareInterceptor. Perhaps it exists but certain dependencies are not available? - interceptor - jar:file:/D:/ghl/apache-tomcat-6.0.20/wtpwebapps/SS/WEB-INF/lib/struts2-portlet-plugin-2.1.8.1.jar!/struts-plugin.xml:48:114
at com.opensymphony.xwork2.ObjectFactory.buildInterceptor(ObjectFactory.java:202)
解决
删除:struts2-portlet-plugin-2.1.8.1.jar
问题:
严重: Dispatcher initialization failed
java.lang.NullPointerException
at org.apache.struts2.osgi.OsgiConfigurationProvider.init(OsgiConfigurationProvider.java:70)
解决:
删除:struts2-osgi-plugin-2.1.8.1.jar
问题:
严重: Dispatcher initialization failed
java.lang.RuntimeException: java.lang.RuntimeException: com.opensymphony.xwork2.inject.DependencyException: com.opensymphony.xwork2.inject.ContainerImpl$MissingDependencyException: No mapping found for dependency [type=java.lang.String, name='actionPackages'] in public void org.apache.struts2.config.ClasspathPackageProvider.setActionPackages(java.lang.String).
at com.opensymphony.xwork2.inject.ContainerBuilder$4.create(ContainerBuilder.java:132)
解决:
修改web.xml:
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
<init-param>
<param-name>actionPackages</param-name>
<param-value>com.ghl</param-value>
</init-param>
</filter>
问题:
警告: Could not find action or result
There is no Action mapped for namespace / and action name HelloWorld. - [unknown location]
at com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:178)
解决:
把 struts.xml文件放到WEB-INF/classes目录下
问题:
java.lang.NoSuchMethodException: com.ghl.HelloWorld.index()
java.lang.Class.getMethod(Unknown Source)
org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.getActionMethod(AnnotationValidationInterceptor.java:75)
解决:
HelloWorld.java中追加方法:
public String index(){
log.info("index");
return SUCCESS;
}