元素类型“struts-config”的内容;必须匹配 “(datasource?,form-beans?
我编写了一个带有登录页面和注册页面的小型 struts 应用程序。 如果我登录,我会看到成功页面。如果我注册,我将检查密码并确认密码字段,如果它们匹配,我将获得成功页面,否则失败页面。
我没有使用任何数据库。我编写了所需的 Form Beans、其中的 Action 类。
在 struts-config.xml
中,
标记处显示错误:
“元素类型“struts-config”的内容必须匹配 “(数据源?,form-beans?,全局转发?,动作映射?)”
如何解决这个问题?我使用 Eclipse 作为我的 IDE。
I wrote a small struts application with a login page and registration page.
If I login I get a success page. If i register, i will check the password and confirm password fileds if they match i get a success page else failure page.
I did not use any database. I wrote the required Form Beans, Action Classes of those.
In struts-config.xml
it is showing an error at the <struts-config>
tag:
"The content of element type “struts-config” must match
“(datasource?,form-beans?,global-forwards?,action-mapping?)"
How to resolve this problem? I am using Eclipse as my IDE.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
是的,根据架构,
struts-config.xml
无效,但随着应用程序正在运行,这只是一个验证问题。要详细说明为什么它在子元素的顺序的上下文中无效 - 如果验证器告诉您.........那么这意味着eg(为简洁起见,减少了示例):
...是模式的有效实现,而eg . ..
...不是。顺便说一下,这是由于 有问题的 Struts 1.0 DTD 说...
...并且要求子元素具有一定的顺序,这不是 DTD 作者无意中所做的事情,而是由于以下事实:
Yes, the
struts-config.xml
is invalid according to the schema, but as the app is working, it's only a validation issue. To expand on why it is invalid in the context of the order of the child elements - If the validator is telling you that......then that means that e.g. (reduced examples for brevity):
...is a valid implementation of the schema, while e.g. ...
...is not. This, by the way, is due to the fact that the Struts 1.0 DTD in question says...
...and by that demands a certain order of child elements. This is not something that the DTD authors do inadvertently, but due to fact that:
您的 struts-config.xml 文件无效。
Struts-config.xml 是一个 XML 文件,因此可以针对 DTD 或 XML-Schema。
您在 Eclipse 中看到的错误是由于 struts-config.xml 文件根据其 DTD 进行验证而验证失败造成的。最有可能的是,它期望您的标签按特定顺序排列,而您没有那样编写它们,您添加了 DTD 中未指定的标签,您拼写错误了一些标签等。
查看 struts-config DTD,然后查看您的 struts-config.xml 文件以查看它们的不同之处。
PS:DTD 有多个版本,因此请确保您选择的是正确的版本。
http://struts.apache.org/dtds/struts-config_1_0.dtd
http://struts.apache.org/dtds/struts-config_1_1.dtd
http://struts.apache.org/dtds/struts-config_1_2.dtd
http://struts.apache.org/dtds/struts-config_1_3.dtd
http://struts.apache.org/dtds/struts-config_1_4.dtd
Your struts-config.xml file is invalid.
Struts-config.xml is an XML file and as such can be validated against a DTD or an XML-Schema.
The error you are seeing in Eclipse is a result of the struts-config.xml file being validated against its DTD and the validation fails. Most likely it is expecting your tags to be in a specific order and you didn't write them that way, you added tags that are not specified in the DTD, you misspelled some tag etc.
Look at the struts-config DTD and then at your struts-config.xml file to see where they differ.
P.S. there are more versions of the DTD so make sure you are looking at the right one.
http://struts.apache.org/dtds/struts-config_1_0.dtd
http://struts.apache.org/dtds/struts-config_1_1.dtd
http://struts.apache.org/dtds/struts-config_1_2.dtd
http://struts.apache.org/dtds/struts-config_1_3.dtd
http://struts.apache.org/dtds/struts-config_1_4.dtd
元素的顺序很重要。例如
元素必须在之前
元素等。The elements' order matter. For example
<form-beans></form-beans>
elementmust be before
<global-forwards></global-forwards>
element etc.我正在使用
struts-config_1_3.dtd
。当我在struts-config.xml
中添加
标记时,我在struts-config.xml
中也遇到了同样的错误。我在
之后添加了
标签code> 标记,因此它抛出错误。正如错误描述所述,标签的顺序应该是
所以我在
之前更改了
。这对我有用。希望这些信息对某人有所帮助。
I am using
struts-config_1_3.dtd
. I also got the same error instruts-config.xml
when I added<global-forwards>
tag instruts-config.xml
.I added
<global-forwards>
tag after<action-mapping>
tag, because of that it was throwing error.As the error description says, the order of the tags should be
So i changed my
<global-forwards>
before<action-mapping>
. And it worked for me.Hope this information help someone.