最近在学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
<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
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货