bestlong 怕失憶筆記

當健忘由隨機逐漸趨向常態時,作筆記是非常必要的

Entries Tagged ‘Eclipse’

Eclipse 出現 The content of element type “package” must match … 錯誤

當我在 Eclipse IDE 環境中學習 struts 2 的過程中,進行編輯 struts.xml 時碰到提示下列的問題

The content of element type “package” must match “(result-types?,interceptors?,default-interceptor-ref?,default-action-ref?,default-class-ref?,global-results?,global-exception-mappings?,action*)”.

有問題的 struts.xml 內容大略如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd">

<struts>
<package name="default" namespace="/" extends="jasperreports-default">
<action name="myJasperTest" class="tw.idv.bestlong.test.action.JasperAction">
<result name="success" type="jasper">
<param name="location">/jasper/our_compiled_template.jasper</param>
<param name="datasource">myList</param>
<param name="format">PDF</param>
</result>
</action>

<result-types>
<result-type name="jasper" class="org.apache.struts2.views.jasperreports.JasperReportsResult"/>
</result-types>
</package>
</struts>

這是因為沒有依據 DTD 中定義的 Element 順序,所以只要調整內容的順序如下就可以通過檢查了。

1
2
3
4
5
6
7
8
9
10
11
12
13
<package name="default" namespace="/" extends="jasperreports-default">
<result-types>
<result-type name="jasper" class="org.apache.struts2.views.jasperreports.JasperReportsResult"/>
</result-types>

<action name="myJasperTest" class="tw.idv.bestlong.test.action.JasperAction">
<result name="success" type="jasper">
<param name="location">/jasper/our_compiled_template.jasper</param>
<param name="datasource">myList</param>
<param name="format">PDF</param>
</result>
</action>
</package>

Leave a Comment

讓 Eclipse 支援多種 JDK 版本的設定方式

不同的 Java 專案可能會因為歷史悠久而需要用到不同版本的 JDK 來編譯。
在 Eclipse 的環境下,進入 Window > Preferences > Java > Installed JREs
然後點選 Add 選擇 Standard VM 指定 JRE home 到 JDK 安裝的位置,讓 Eclipse 知道其他 JDK 的存在。

Leave a Comment

EasyEclipse 讓 Eclipse 更容易安裝使用

EasyEclipse 是針對不同開發者的工作類型將 Eclipse 重新打包過的專屬開發工具,得以簡化安裝、設定的過程。
以 Java 領域來說分成 Expert、Desktop、Server、Mobile、Plugins and RCP Apps等多個的安裝版本。
而 Web and dynamic languages 領域有 LAMP、PHP、Ruby and Rails、Python 等的安裝版本。
還有 C and C++ 的安裝版本。

http://www.easyeclipse.org

Leave a Comment

如何確認 Eclipse 有載入哪些外掛

使用 Eclipse 有時會需要手動安裝外掛,例如:VE(Visual Editor)、EMF(Eclipse Modeling Framework)、GEF(Graphical Editing Framework)等等外掛,不過卻經常會發生安裝完成後沒有任何改變的狀況。想要確定外掛是否有被 Eclipse 載入使用,可以依據下列過程檢查:

點選功能表 Help > Software Updates > Manage Configuration 後會顯示 Product configuration 對話框。然後展開左側的 Tree 就可以看到有被載入的外掛列表。

基本上安裝外掛最好一次一個最穩當,每裝一個就啟動 Eclipse 一次並依上列程序檢查載入狀況。若是沒有載入成功可以試試再重新啟動 Eclipse 但是加上 -clear 參數,這樣會初始化所有的插件設定,會清除無效的插件並重新載入有效的插件。

Leave a Comment

讓 Eclipse RCP Application 執行啟動直接顯示視窗最大化

Eclipse RCP 程式執行啟動的視窗大小是由程式中的 setInitialSize() 決定的,想要顯示 400 x 300 大小的視窗,如下列程式碼片段:

1
2
3
4
5
6
public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor {
    public void preWindowOpen() {
        IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
        configurer.setInitialSize(new Point(400, 300));
    }
}

不過大部分的程式應該都是啟動後就會直接顯示最大化的視窗,可以在同一個 class 中加入下列程式碼。

1
2
3
4
5
public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor {
    public void postWindowOpen(){
     getWindowConfigurer().getWindow().getShell().setMaximized(true);
    }
}

Leave a Comment

  • 工商服務

    廣告讀取中...
  • 近期留言

  • 標籤

  • 彙整