eclipse爲SSH框架.xml文件添加自動提示功能

一、spring

 

用eclipse,在導入相應的包後(有人說不導包也有提示,因爲默認的eclipse導入了jdk的包),eclipse會有代碼提示功能。
那麼XML文件能不能也這樣呢?其實也是可以的,只不過導包的地方不一樣。下面以spring爲例(雖然Myeclipse6.5中已經集成了,這裏只是示範說明)。

[html] view plaincopy

  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:http://www.springframework.org/schema/beans/spring-beans-3.0.xsd

點擊確定

將spring配置文件關閉再重新打開即可。可以使用Eclipse XML Editor打開這些xml文件。

二、hibernate

 

  在編輯 *.hbm.xml 文件時,myeclipse 帶有自動提示功能,但 eclipse 是沒有自動提示功能的。需要自己手工加上:
          1、打開項目中任意一個 *.hbm.xml 文件,看一下文件頭,形如以下:

 

[html] view plaincopy

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



          找到 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 裏輸入第一步裏得到的http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd。OK。
          再打開 eclipse 中的 *.hbm.xml 文件,編輯時就可以像 myeclipse 中那樣擁有自動提示功能了。

 

三、struts2

1.配置文件:

[html] view plaincopy

  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://struts.apache.org/dtds/struts-2.3.dtd

轉自:http://blog.csdn.net/tydldd1/article/details/8060965

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章