博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
eclipse为SSH框架.xml文件添加自动提示功能
阅读量:4115 次
发布时间:2019-05-25

本文共 2123 字,大约阅读时间需要 7 分钟。

.xsd .dtd文件要从jar包文件中解压获取

一、spring

 

用eclipse,在导入相应的包后(有人说不导包也有提示,因为默认的eclipse导入了jdk的包),eclipse会有代码提示功能。
那么XML文件能不能也这样呢?其实也是可以的,只不过导包的地方不一样。下面以spring为例(虽然Myeclipse6.5中已经集成了,这里只是示范说明)。

[html]
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <beans  
  3.     xmlns="http://www.springframework.org/schema/beans"  
  4.     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
  5.     xmlns:p="http://www.springframework.org/schema/p"  
  6.     xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">  


进入:window -> Preference... -> MyEclipse -> Editors -> XML ->XML Catalog

选择:选中“User Specified Entries”,点击“Add...”按钮

填入:

location: 请选择本地文件系统上SPRING_HOME\schema\beans\spring-beans-3.0.xsd 文件
Key Type: 选择Schema Location
Key:

点击确定

将spring配置文件关闭再重新打开即可。可以使用Eclipse XML Editor打开这些xml文件。

二、hibernate

 

  在编辑 *.hbm.xml 文件时,myeclipse 带有自动提示功能,但 eclipse 是没有自动提示功能的。需要自己手工加上:

          1、打开项目中任意一个 *.hbm.xml 文件,看一下文件头,形如以下:

 

[html]
  1. <?xml version="1.0" encoding="utf-8"?>      
  2. <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"    
  3. "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">      

          找到 (视 hibernate 版本不同有所不同)。
          2、将项目中用到的 hibernate-core-4.1.7.Final.jar解压缩,找到解压缩后的 org 文件下的 hibernate 文件下的 hibernate-mapping-3.0.dtd 文件。
          3、eclipse -> Window -> Preferences -> Web and XML -> XML Catalog,选择 XML Catalog Entries 的 Add... 按钮,在弹出的 Add XML Catalog Entry 对话框里,Location 里选择第二步里得到的 hibernate-mapping-3.0.dtd,Key Type 选择 URI,Key 里输入第一步里得到的。OK。
          再打开 eclipse 中的 *.hbm.xml 文件,编辑时就可以像 myeclipse 中那样拥有自动提示功能了。

 

三、struts2

1.配置文件:

[html]
  1. <?xml version="1.0" encoding="UTF-8" ?>  
  2. <!DOCTYPE struts PUBLIC  
  3.     "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"  
  4.     "http://struts.apache.org/dtds/struts-2.3.dtd">  

2.在struts安装包里找struts-2.3.dtd文件

3、eclipse -> Window -> Preferences -> Web and XML -> XML Catalog,选择 XML Catalog Entries 的 Add... 按钮,在弹出的 Add XML Catalog Entry 对话框里,

将llib目录下的struts2-core-2.3.4.1.jar解压缩(struts-2.3.4.1-all\struts-2.3.4.1\lib\struts2-core-2.3.4.1),找到里面的struts-2.3.dtd。

location: 请选择本地文件系统上STRUTS_HOME\struts-2.3.4.1\lib\struts2-core-2.3.4.1\struts-2.3.dtd文件
Key Type: 选择URI

Key:

转载地址:http://giupi.baihongyu.com/

你可能感兴趣的文章
怎样高效入门 Vue?
查看>>
JS 引擎 V8 新机制:JIT-less 模式
查看>>
2019年哪些外快收入可达到2万以上?
查看>>
毕业10年,一个上海女程序员的职业之路—02
查看>>
互联网让铁饭碗再见!刚刚宣布!百万人或将无眠!
查看>>
【JavaScript 教程】标准库—Date 对象
查看>>
关于Vue 3.0前端开发者必须知道的不仅仅是Proxy...
查看>>
Sublime Text查找&替换
查看>>
前阿里手淘前端负责人@winter:前端人如何保持竞争力?
查看>>
【JavaScript 教程】面向对象编程——实例对象与 new 命令
查看>>
2019年哪些外快收入可达到2万以上?
查看>>
我在网易做了6年前端,想给求职者4条建议
查看>>
马云:无论被拒绝多少次,请相信自己
查看>>
面试加分项之 Nginx 反向代理与负载均衡
查看>>
我卖掉北京500万的房产,在老家生活的这两年……
查看>>
马云:我不为996辩护,我向奋斗者致敬
查看>>
零基础学网站制作系列教程-02
查看>>
不想工作了怎么破?那就去这4个地方看一看
查看>>
【JavaScript 教程】面向对象编程——this 关键字
查看>>
一名 40 岁“老”程序员的反思~
查看>>