Adding DTD support manually in MyEclipse

Source: Internet
Author: User

First, MyEclipse:

1. Find the DTD file corresponding to the XML file first

(This information can be found in general file headers)

(The DTD constraint file for Web. XML is inside Servlet.jar; struts and hibernate are in their own jar packages)

2, Window->preference->myeclipse enterprise->files and Editors->xml->xml catalog->User Specified Entries->add

3. Key Type Select URI

Key Select the key address referenced in DocType in the XML file

(for example, dwr3.0 is using:-//getahead limited//dtd Direct Web Remoting 3.0//en)

Location Select the full path of the DTD file on the local hard drive (recommended in MyEclipse, see plugin Specified Entries)

Two

In the myeclipse to let Struts.xml file automatically prompt function, I thought this is very simple, as long as the Struts.xml file corresponding to the DTD file association on the line, but then I was the first time the configuration, some problems are not very clear, so in the MyEclipse set the A bit, when I entered the "<" in the Struts.xml file is not prompted, but press the shortcut key "alt+/" is a hint, after a while or no hint, so give up. Today learning struts2 abnormal handling, and think of this problem, so after nearly half an hour, combined with various solutions on the Internet, finally prompted the emergence of. So immediately wrote this blog, share. I think it's quite useful.

Online quite a lot of the solution is to associate a DTD file, here I first explain, whether it is to associate a DTD file, or do not associate a DTD file, I think the correlation is better, perhaps the day of the problem.

1. First open the MyEclipse window and select the "Preferences" option under the "Window" menu, as shown in the figure:

2. Open the Preferences dialog box, select the XML Catalog option on the left side of the XML option, and then select the Add button on the right to open the following dialog box, as shown in the figure: (If there is no XML option, then the search XML in the options is as follows:)

3, in the Open dialog box, enter the location of the DTD file corresponding to the Struts.xml file, it is best not to choose a Chinese directory, sometimes it is because the Chinese directory is selected, so there is no prompt, select the "File System" button, Find the location of the DTD file, someone said to extract a jar package, there is a need for the DTD file, in fact, as long as we download the STRUTS2 installation package, in a folder inside the necessary DTD file does not need us to extract, here my Struts2 directory is my Computer e-packing directory , in which the following path is found "E:\struts-2.3.4.1\src\core\src\main\resources", below this path there is a "struts-2.3.dtd" file, this is the file we are looking for, so when the file is selected, Location is: "E:\struts-2.3.4.1\src\core\src\main\resources\struts-2.3.dtd", Next in "Key type" where the type is "URI", "key" The place to enter "HTTP://STRUTS.APACHE.ORG/DTDS/STRUTS-2.3.DTD", this sentence can be found on the DTD file doctype (or in "key type" where the type "public ID" in the "key "Enter"-//apache software foundation//dtd Struts Configuration 2.3//en "Check alternative web Address:http://struts.apache . org/dtds/struts-2.3.dtd). As shown in the figure:

Click "OK" button to return, save exit.

This is just one of the steps that we want to appear automatically prompt, when I set the completion, or press "alt+/" appear prompt, press "<" still no hint, so again on the Internet to check a bit, this just know need to change editor, for MyEclipse, For the Struts.xml file, its default setting is not set to MyEclipse's XML editor, but instead is set to the XML editor for MyEclipse Struts2, so we want to set the editor for the XML file to be the MyEclipse XML editor. The specific steps are as follows:

1, first open the MyEclipse window, select the "Window" menu under the "Preferences" option, select "General" under the "File Associations" option, on the right side of the page in the "File types" select "*." XML ", select MyEclipse XML Editor at the bottom of the associated editor, click the" Default "button to set it to default, click the OK button to save the exit. As shown in the figure:

This will prompt you when we enter "<" in the Struts.xml file, as shown in the figure:

Note: The version of MyEclipse I am using is STRUTS2 version 2.3.4.


Same method to add struts2 validation DTD

Key Type:public ID

Key:-//opensymphony group//xwork Validator 1.0.3//en (old) or (-//apache struts//xwork Validator 1.0.3//en) (new)

Select alternative web address:http://www.opensymphony.com/xwork/xwork-validator-1.0.3.dtd

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.