There is a slight change in 'My struts-config.xml'. sorry, <action-mappings> is missing in 'My struts-config.xml' in the above question. But <action-mappings> is present in my origianl struts-config.xml. so that may not have caused the error. so what caused the error?
I can see at least two errors: There is no closing </form-beans> tag. Also, at least one of your <message-resources> stanzas must have a key attribute. Also check out question 10 in the JavaRanch Struts FAQ.
Thanks for being up front about the fact that your post didn't accurately represent what's in your config file. However, this brings up a "pet peeve" of mine, so forgive while I unload a little.
For a person trying to be helpful, having spent some time searching through a post for some minute detail that might be the cause of someone's problem, then finally finding something and pointing it out, there's nothing more irritating than being told "Oh, yeah, I just copied it wrong into my post. That's not the problem. Can you help me find the real problem?"
If you're going to ask other developers to spend their time looking for problems in your code, don't you think you at least owe them the courtesy of taking the time to make sure the code you put in your post accurately represents the code that's causing you the problem? [ March 11, 2007: Message edited by: Merrill Higginson ]
You cannot have two <message-resources> tags in the same struts-config file unless one of them is defined by a key attribute. Example:
In the above example, "MessageResources" is the default message resource, and the "TestMessageResources" is a secondary resource. In order to reference a secondary resource, you must specify a bundle attribute. So, for example, if I want to reference a message in the "TestMessageResources", I would specify the following:
For more detailed information on this, see this link.
what does DTD stand for?
A DTD (Data Type Definition) is the governing document for an XML file. It declares the rules for what elements can be in the XML file, their frequency, and the order in which they appear. If your Struts-config.xml file does not conform to the rules in the DTD file declared at the top of the document, Struts will throw an exception stating that it cannot parse the XML file.
At the beginning of your struts-config.xml file, you should have a declaration that looks like this:
The last line of this declaration is a real URI that points to the location of the DTD. You can use your browser to download it. The DTD declared is dependent on the version of Struts you're using. If you're using version 1.2.x, then the DTD will be different. Since I'm using 1.3.8, the DTD is declared as version 1.3.
Here's a tip: I almost never create a struts-config.xml file from scratch. I'd recommend that you unzip the struts-blank.war file that came with the download and copy the struts-config.xml file found in that application into your application and use it as a template for your config file.