java - 元素类型 “struts-config” 的内容必须匹配“(datasource?,form-b​​eans?

标签 java eclipse struts dtd struts-config

我写了一个带有登录页面和注册页面的小型 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-b​​eans?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5163716/

相关文章:

Java GC 停止并复制

java - Apache Nutch 2.3.1 插件无法工作

java - 使用 tomcat、struts2 和 eclipse 的 java web 应用程序上的 404 错误

redirect - Struts 2 'redirectAction' 协议(protocol)从HTTPS改为HTTP

java - 我应该如何使用 junit 对 Spring、Hibernate 和 Struts 进行单元测试

java - Spring集成TCP服务器打印传入消息

java - 如何强制Tomcat(部署在eclipse中)自动重新加载更改的文件

java - ValidateJarFile(D :\path\) - jar not loaded. 请参阅 Servlet 规范 3.0,第 10.7.2 节。违规类 : javax/servlet/Servlet. 类

java - Tomcat 7.0.32 无法部署我的项目

java - 我的 do while 循环在一次迭代后停止。我该如何继续下去?