appletviewr - getParameter 返回 null
我编译此代码并使用小程序查看器进行测试。但我看到字符串“value: null”而不是“value: VALUE”。
1)我做错了什么?
/* <applet code="Demo" width="100" height="100">
<param name="name1" value="VALUE">
</applet>
*/
import java.applet.*;
import java.awt.*;
public class Demo extends Applet
{
String str=null;
public void init()
{
str=getParameter("name1");
}
public void paint(Graphics g)
{
g.drawString("value: "+str,100,50);
}
}
但是,如果我打开与 Demo.class 位于同一文件夹中的 HTML 文件,
<html>
<body>
<applet code=Demo.class width="200" height="200" >
<param name="name1" value="VALUE">
</applet>
</body>
</html>
我会得到所需的输出“值:VALUE”。 (但是对于这个结果,我应该杀死进程java.exe
,否则尽管 Demo.class 已更新,但我会得到未更新的小程序)。
2)为什么在我更新java.exe
之前小程序不会更新?
I compile this code and use applet viewer for testing. But I see string "value: null" instead of "value: VALUE".
1) What did I do wrong?
/* <applet code="Demo" width="100" height="100">
<param name="name1" value="VALUE">
</applet>
*/
import java.applet.*;
import java.awt.*;
public class Demo extends Applet
{
String str=null;
public void init()
{
str=getParameter("name1");
}
public void paint(Graphics g)
{
g.drawString("value: "+str,100,50);
}
}
But if I open HTML file which is located in same folder with Demo.class
<html>
<body>
<applet code=Demo.class width="200" height="200" >
<param name="name1" value="VALUE">
</applet>
</body>
</html>
I get desired output "value: VALUE". (However for this result I should kill process java.exe
, otherwise I get non-updated applet although Demo.class was updated).
2) Why won't the applet update until I will the java.exe
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我在此处的小程序查看器中获取
value: VALUE
。但那是在源代码顶部的注释中将小程序元素的宽度从 100 增加到 200 之后。比这更细,文本就会被截断。I am getting
value: VALUE
in the applet viewer here. But then that is after increasing the width of the applet element from 100 to 200 in the comment at the top of the source. Thinner than that, and the text becomes truncated.