首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Exception >

struts2.0 org.xml.sax.SAXParseException: Element type bean must be declared报有异常

2014-01-26 
初学用Struts 2.0作了一个简单的页面显示,但他抛异常,请大侠们帮忙看一下: 我导入了这几个包: ognl-2.6.7.j

初学用Struts 2.0作了一个简单的页面显示,但他抛异常,请大侠们帮忙看一下:
我导入了这几个包:
ognl-2.6.7.jar
struts2-api-2.0.1.jar
freemarker-2.3.4.jar
commons-logging-1.0.4.jar
struts2-core-2.0.1.jar
xwork-2.0-beta-1.jar
这是要打开的页面:SayHello.jsp------------------------
<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
<title>Say Hello </title>
</head>
<body>
<h3>Say "Hello" to: </h3>
<s:form action="HelloWorld">
Name: <s:textfield name="name" />
<s:submit />
</s:form>
</body>
</html>

后台ACTION为:HelloWorld.java-----------------------

package tutorial;

import com.opensymphony.xwork2.ActionSupport;

public class HelloWorld extends ActionSupport {
private String name;

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String execute() {
System.out.println("----------------");
name = "Hello, " + name + "!";
return SUCCESS;
}
}

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">
<display-name>Struts 2.0 Hello World </display-name>
<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.html </welcome-file>
</welcome-file-list>

</web-app>

struts.xml配置文件-----------------------------------------

<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<include file="struts-default.xml"/>
<package name="tutorial" extends="struts-default">
<action name="HelloWorld" class="tutorial.HelloWorld">
<result>HelloWorld.jsp </result>
</action>
</package>
</struts>

在浏览器中打开SayHello.jsp页面时,报异常情况:--------------------------------------------------
严重: Element type "bean" must be declared. at (null:30:72)
org.xml.sax.SAXParseException: Element type bean must be declared.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.handleStartElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.emptyElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)         

热点排行