一、spring
用eclipse,在導入相應的包後(有人說不導包也有提示,因爲默認的eclipse導入了jdk的包),eclipse會有代碼提示功能。
那麼XML文件能不能也這樣呢?其實也是可以的,只不過導包的地方不一樣。下面以spring爲例(雖然Myeclipse6.5中已經集成了,這裏只是示範說明)。
[html] view plaincopy
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
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
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"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
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"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