我写了一个带有登录页面和注册页面的小型 struts 应用程序。 如果我登录,我会看到一个成功页面。如果我注册,我将检查密码并确认密码文件是否匹配我得到一个成功页面,否则失败页面。
我没有使用任何数据库。我编写了所需的 Form Beans,它们的操作类。
在struts-config.xml
它在 <struts-config>
处显示错误标签:
"The content of element type “struts-config” must match “(datasource?,form-beans?,global-forwards?,action-mapping?)"
如何解决这个问题?我使用 Eclipse 作为我的 IDE。
最佳答案
是的,根据架构,struts-config.xml
是无效的,但由于应用程序正在运行,这只是一个验证问题。扩展为什么它在子元素顺序的上下文中是无效的——如果 validator 告诉你...
The content of element type “struts-config” must match “(datasource?,form-beans?,global-forwards?,action-mapping?")
...那么这意味着例如(为简洁起见减少了示例):
<struts-config>
<datasource>...</datasource>
<form-beans>...</form-beans>
<global-forwards>...</global-forwards>
<action-mapping>...</action-mapping>
</struts-config>
...是模式的有效实现,而例如...
<struts-config>
<datasource>...</datasource>
<global-forwards>...</global-forwards>
<form-beans>...</form-beans>
<action-mapping>...</action-mapping>
</struts-config>
...不是。顺便说一下,这是因为 Struts 1.0 DTD in question说……
<!ELEMENT struts-config (data-sources?,form-beans?,global-forwards?,action-mappings?)>
...因此需要子元素的特定顺序。这不是 DTD 作者无意中做的事情,而是由于以下事实:
Declaring unordered lists with occurrence constraints in DTD will often result in long or complicated looking declarations. 1
关于java - 元素类型 “struts-config” 的内容必须匹配“(datasource?,form-beans?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5163716/