Eclipese编写XML自动提示问题

来源:互联网 发布:剑三七秀萝莉捏脸数据 编辑:程序博客网 时间:2024/05/11 16:58

     在Eclipse中编写Spring、ibatis、hibernate等配置文件时,可能不会出现元素的提示功能。在网上也有很多资料,无非是添加DTD约束和XSD约束。但是在添加完这些步骤之后可能还会没有提示,可能问题是如下:

1.确定XML文件的默认打开方式XML-editor,否则不会出现自动提示,本人开始就是出现这个原因。对于不是XML-editor自动打开的可以到window->preferences->general->editors->file associations 中选中*.xml的下面的打开方式,并选中xml-editor为默认的即可。那样以后打开xml文件时默认的打开方式就是xml-editor;


2.确定打开了自动提示功能。这一点可以到Window > Preferences > Xml > Xml Files > Editor > Content Assist > Auto activation > Prompt when these characters are inserted看到 ,设置框中默认是 <=;


3.确定上面两点都没问题后,再按照以下方式来配置(以添加Spring的配置文件为例,其他的类似):

  DTD 类型约束文件
    1. Window->Preferences->XML->XML Catalog->User Specified Entries窗口中,选择Add 按纽    
    2.在Add XML Catalog Entry 对话框中选择或输入以下内容:
        Location: F:\soft\programmingSoft\Framework\Ibatis\sql-map-config-2.dtd
        Key Type: URI
        KEY: http://ibatis.apache.org/dtd/sql-map-config-2.dtd
        
  XSD 类型约束文件
    1. Window->Preferences->XML->XML Catalog->User Specified Entries窗口中,选择Add 按纽       
    2.在Add XML Catalog Entry 对话框中选择或输入以下内容:
        Location: F:\soft\programmingSoft\Framework\Spring\spring-framework-2.5.6.SEC01-with-dependencies\spring-framework-2.5.6.SEC01\dist\resources\spring-beans-2.5.xsd
        Key Type: Schema Location
        KEY: http://www.springframework.org/schema/beans/spring-beans-2.5.xsd

原创粉丝点击