MyEclipse 为xml添加本地的dtd文件

在使用Eclipse或MyEclipse编辑XML文件的时候经常会碰到编辑器不提示的现象,这常常是因为其xml文件需要参考的DTD文件找不到,还有因为网络的问题不能及时提示而产生的。Eclipse/MyEclipse可以将本地的DTD文件添加至Eclipse中。以添加struts2的DTD文件为例,步骤如下:

  • window - preferences - xml catalog
  • add - location 选择 File System
  • Key Type 选择URI

Key 填入 http://struts.apache.org/dtds/struts-2.0.dtd (struts.xml文件根元素)

下图 为validation的例子

 

<!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>

原文地址:https://www.cnblogs.com/xj626852095/p/3648021.html