eclipse如何添加本地的dtd文件

在使用Eclipse或MyEclipse编辑XML文件的时候经常会碰到编辑器不提示的现象,这常常是因为其xml文件需要参考的DTD文件找不到,或是因为网络的问题不能及时提示而造成的。

Eclipse/MyEclipse可以将本地的DTD文件添加至Eclipse中。

以添加struts2的DTD文件为例,步骤如下:

1:Window -->  Preferencrs -->  XML --> XML Catalog --> add 

2:location 选择 File System,然后选择你的本地DTD文件。

3:Key Type 选择URI。

4:Key 填入下面第三行的网址

<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
    "http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
    <constant name="struts.enable.DynamicMethodInvocation" value="false" />
    <constant name="struts.devMode" value="false" />
    <include file="example.xml"/>
    <!-- Add packages here -->
</struts>

 

5:保存之后,重启Eclipse/MyEclipse。

猜你喜欢

转载自guoying252166655.iteye.com/blog/1972217