最近在学Struts2,从apache网站上下载了一个程序 struts-2.1.8.1-apps  包, 从里面 导了不得 ognl-2.7.3.jar,xwork-core-2.1.6commons-logging-api-1.1struts2-core-2.1.8.1freeer-2.3.15这几个包进去了,web.xml文件<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" 
xmlns="http://java.sun.com/xml/ns/j2ee" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<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>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="mldn" namespace="/" extends="struts-default">
<action name="login" class="com.xwei.dao.LoginAction">
<result name="suc">
/hello.jsp
</result>
<result name="error">
/errors.jsp
</result>
</action>
</package>
</struts>
index.jsp
  <body>
     <form action="login.action" method="post"> 
     姓名:<input type="text" name="username"/><br>
     <input type="submit" value="提交"/>
     </form>
  </body>
java 代码
package com.xwei.dao;
import com.opensymphony.xwork2.ActionSupport;
public class LoginAction extends ActionSupport { private String username; public String getUsername() {
return username;
} public void setUsername(String username) {
this.username = username;
}

public String execute() throws Exception
{
if("xwei".equals(username))
{
return "suc";
}
else
{
return "error";
}
}
}
严重: Dispatcher initialization failed
Unable to load configuration. - bean - jar:file:/C:/Program%20Files/tomcat-6.0.14/webapps/Tests/WEB-INF/lib/struts2-core-2.1.8.1.jar!/struts-default.xml:47:178

解决方案 »

  1.   

    你的tomcat没有启动起来吧。你启动了服务器后,不要先输入url,先看一下后台有没有报错.如果有错,贴出来。如果没有那么你就先到tomcat下去。即:http://localhost:8080/然后看你的工程有没有发布.如果发布了还是不行的话。你就要导入upfile那个包。(不知道有没有写错哈,反正是上传文件的那个).然后再试看!再不行的话在贴出来哈
      

  2.   

    初始化configuration失败,看你的配置没什么问题,你看看你的struts2-core-2.1.8.1.jar里面的struts-default.xml