Re: [問題] Eclipse & JCreator & Applet
※ 引述《ibmoldtwo (BMJ)》之銘言:
: 各位大大好,
: 我在HTML網頁傳遞參數給JAVA Applet時發生一些問題!
: --------------------------------------------------------------
: 目前工具:Eclipse
: 檔案配置如下:
: Javatest|
: |-src|
: |-(預設套件)|
: |-testApplet.java
: html檔我已寫好放置我所設定的classes中。
: 編譯後則出現
: java.lang.NumberFormatException: null
: at java.lang.Integer.parseInt(Unknown Source)
: at java.lang.Integer.parseInt(Unknown Source)
: at testApplet.init(testApplet.java:26)
: at sun.applet.AppletPanel.run(Unknown Source)
: at java.lang.Thread.run(Unknown Source)
我想編譯時決不會出現上述的情況,這是你使用 Eclipse 來執行 applet 時,產生
的 exception。
大概可以猜出你是使用 Eclipse 中的 run as applet command 來測試你的 applet,
而且 testApplet 的 line 26 很可能是這樣寫:
int n = Integer.parseInt(getParameter("some_parameter_name"));
使用 run as applet 來運行 applet 是不需要有 html 檔的,也就是說你原本預期
透過 applet - getParamter(String) method 可以獲得在 html 裡 pass 進來的
parameters 實際上不是如你預期一樣(Eclipse 不會去讀 html)。你必須要在 run
configuration 裡去設定要 pass 給 applet 的參數。
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 218.173.140.244
推
05/05 08:40, , 1F
05/05 08:40, 1F
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 2 之 2 篇):