The contents of the struts-config element type must match (datasource ?, Form-beans?

I wrote a small locations app with a registration page and a registration page. If I log in, I get a success page. If I register, I will verify the password and confirm that the files with the password, if they match, I get the page of the failed page with an error.

I did not use the database. I wrote the required Beans Form, the Action classes from them.

In struts-config.xml , the <struts-config> tag is displayed:

"The contents of the struts-config element type must match" (Data source ?, Form-beans ?, global-forward ?, action-mapping?) "

How to solve this problem? I am using Eclipse as my IDE.

+4
source share
3 answers

Yes, struts-config.xml invalid according to the schema, but as the application works, this is only a validation problem. To find out why this is unacceptable in the context of the order of the children - if the validator tells you that ...

The content of the struts-config element type must match "(Data source ?, Form-beans ?, global-forward ?, action-mapping?")

... then this means, for example, (abridged examples for brevity):

 <struts-config> <datasource>...</datasource> <form-beans>...</form-beans> <global-forwards>...</global-forwards> <action-mapping>...</action-mapping> </struts-config> 

... is a valid implementation of the circuit, while, for example, ...

 <struts-config> <datasource>...</datasource> <global-forwards>...</global-forwards> <form-beans>...</form-beans> <action-mapping>...</action-mapping> </struts-config> 

... no. This, by the way, is due to the fact that Struts 1.0 DTD in the question says ...

 <!ELEMENT struts-config (data-sources?,form-beans?,global-forwards?,action-mappings?)> 

... and thus requires a certain order of children. This is not something that DTD authors do unintentionally, but because:

Declaring unordered lists with restrictions on appearance in DTDs will often lead to long or complex looking applications. 1

+2
source

Your struts-config.xml file is invalid.

Struts-config.xml is an XML file and as such can be checked against a DTD or XML schema .

The error you see in Eclipse is the result of checking the struts-config.xml file for its DTD, and the check fails. Most likely, you expect your tags to be in a certain order, and you won’t write them that way, you added tags that are not specified in the DTD, you wrote the tag incorrectly, etc.

Look at the struts-config DTD and then the struts-config.xml file to find out where they differ.

PS there are more versions of DTD, so make sure you look at the correct 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

+1
source

Materiality of elements. For example, the <form-beans></form-beans> element must be before <global-forwards></global-forwards> , etc.

-1
source

Source: https://habr.com/ru/post/1341931/


All Articles