日期:2014-05-17  浏览次数:20665 次

struts2包加全了还是报错
我用了struts2.1.8, tomcat6, eclipse Java EE IDE



HTML code
严重: Dispatcher initialization failed
Unable to load configuration. - bean - jar:file:/E:/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/struts2/WEB-INF/lib/struts2-core-2.1.8.jar!/struts-default.xml:29:72
    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)


网上大多数人都说要加commons-fileupload-1.2.1.jar 和commons-io-1.3.2.jar这两个包就解决问题了
我已经加了但还是报了相同的错误。我是把包放在web-inf下的lib里面
commons-fileupload-1.2.1.jar
commons-io-1.3.2.jar
commons-logging-1.0.4.jar
freemarker-2.3.15.jar
ognl-2.7.3.jar
struts2-core-2.1.8.jar
xwork-core-2.1.6.jar


谁帮我看看这是什么原因。

------解决方案--------------------
加的包应该没有问题 我用的跟你一样的版本可以正常运行
看看是不是你的web.xml struts.xml的配置有问题
web.xml
XML code

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
    <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>

------解决方案--------------------
<action name="Login" class="mahayu.st2.LoginAction">

注:LoginAction的路径为com.mahayu.st2.LoginAction

这是映射处理Action的一段,问题在于"class="的指向路径错误,你的处理Action在哪,就必须写正确,否则就会出现如题的异常,意思就是在当前指定的路径下找不到这个Action类文件!

------解决方案--------------------
我用的是MyEclipse7.0 你的提示错误是没找到过滤器!
你不要把包直接放在lib下面,我也曾出现过这问题!在MyEclipse工具下直接复制到lib下要导入的包!
方法:打开web.xml(design)-->Filter-->add-->命名Filter-name,点击Browse-->输入filterD..
会有提示!就OK了,假如没提示,说明你导入的包路径不对,工具找不到文件!