struts2.0运行错误
<?xml version="1.0" encoding="UTF-8"?><web-app version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<filter>
<filter-name>struts1</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>struts1</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
这是web.xml
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<!-- Struts 2的Action必须放在指定的包空间下定义 -->
<package name="strutsqs" extends="struts-default">
<action name="Login" class="li.ze.yi.LoginAction">
<result name="error">/failer.jsp</result>
<result name="success">/success.jsp</result>
</action>
</package>
</struts>
这是struts.xml
但启动服务器的时候出现
2010-5-2 16:13:51 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
信息: Parsing configuration file [struts-default.xml]
2010-5-2 16:13:51 com.opensymphony.xwork2.util.logging.commons.CommonsLogger error
严重: Dispatcher initialization failed
Unable to load configuration. - bean - jar:file:/E:/Tomcat-6.0/apache-tomcat-6.0.10/webapps/struts5/WEB-INF/lib/struts2-core-2.1.8.1.jar!/struts-default.xml:47:178
Caused by: Unable to load configuration. - bean - jar:file:/E:/Tomcat-6.0/apache-tomcat-6.0.10/webapps/struts5/WEB-INF/lib/struts2-core-2.1.8.1.jar!/struts-default.xml:47:178
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:58)
at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:374)
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:418)
... 28 more
Caused by: Unable to load bean: type:org.apache.struts2.dispatcher.multipart.MultiPartRequest class:org.apache.struts2.dispatcher.multipart.JakartaMultiPartRequest - bean - jar:file:/E:/Tomcat-6.0/apache-tomcat-6.0.10/webapps/struts5/WEB-INF/lib/struts2-core-2.1.8.1.jar!/struts-default.xml:47:178
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:221)
at org.apache.struts2.config.StrutsXmlConfigurationProvider.register(StrutsXmlConfigurationProvider.java:101)
at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:169)
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:55)
... 30 more
Caused by: java.lang.NoClassDefFoundError: org/apache/commons/fileupload/RequestContext
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
at java.lang.Class.getDeclaredConstructors(Unknown Source)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:211)
... 33 more
Caused by: java.lang.ClassNotFoundException: org.apache.commons.fileupload.RequestContext
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1358)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1204)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
... 37 more
2010-5-2 16:13:51 org.apache.catalina.core.StandardContext start
严重: Error filterStart
2010-5-2 16:13:51 org.apache.catalina.core.StandardContext start
严重: Context [/struts5] startup failed due to previous errors
有哪个高手请指点一下是怎么加事 运行环境是tomcat6.0 myeclipse7.0 --------------------编程问答-------------------- 少引入了commons-fileupload-1.2.1.jar --------------------编程问答-------------------- 问下: 楼上的你从那里看出来少的这个包了? 少jar包我知道可是具体少那个 你从那看出来的了?
谢谢了啊 --------------------编程问答-------------------- 该引的包的我都引了,之前我把所有的包都引了出错,之后引了必要的包还是不行 --------------------编程问答-------------------- struts.xml里面弄下<package name="default" namespace="/" extends="struts-default">看看是不是路径问题。还有你xml里边的版本要和你的jar包匹配可能是jar包冲突。弄弄看把呵呵 --------------------编程问答-------------------- 缺少 jar包 参考一下struts文档吧 --------------------编程问答-------------------- 我把所有的包都引了还是出错
--------------------编程问答--------------------
我是通过Caused by: java.lang.ClassNotFoundException: org.apache.commons.fileupload.RequestContext判断的。 --------------------编程问答-------------------- 把你引的jar包名都贴出来看看,估计是不兼容。 --------------------编程问答-------------------- 原来是导入固定的包,多引少引都是出错,
xwork-core-2.1.6.jar
commons-logging-1.0.4.jar
commons-fileupload-1.2.1.jar
freemarker-2.3.15.jar
ognl-2.7.3.jar
spring-test-2.5.6.jar
struts-core-2.1.8.1.jar
struts2-json-plugin-2.1.8.1.jar
引入这个8个包就可以了,千万不要多引也不要少引,不然会总报错的 --------------------编程问答-------------------- struts2.1.8最少jar包。
1>.struts-core-2.1.8.1.jar
2>.xwork-core-2.1.6.jar
3>.freemarker-2.3.15.jar
4>.ognl-2.7.3.jar
5>.commons-logging-1.0.4.jar
6>.commons-fileupload-1.2.1.jar
--------------------编程问答-------------------- 估计是导入的时候,导入了两个struts-core.jar吧,建议把jar列出来, --------------------编程问答-------------------- 11楼说的对,我也遇到过类似的问题。按11楼的说法把其中的的一个struts-core.jar包remove掉之后,就没问题了 --------------------编程问答-------------------- jar包冲突了 --------------------编程问答--------------------
+1
补充:Java , Java EE