Applet param 标签有什么用?
如果这个问题很愚蠢,请原谅我,但是 param 标签的意义是什么? 我观看了视频并阅读了教程,非常了解它的作用,但不明白为什么? 看来用户不能使用这个参数标签来输入数据,但是程序员设置了值(从我所看到的)。那么,当我们可以简单地在 .java 文件中完成所有这些操作时,为什么要使用它呢? 一个实际的例子将不胜感激,谢谢!
Forgive me if this question is stupid, however what is the point of the param tag?
I have watched videos and read tutorials and pretty much understand what it does, but don't understand the why?
It seems the user can't use this param tag to input data, but the programmer sets the values (from what I've seen). So why is it used when we can simply do all that in the .java file?
A practical example would be appreciated, thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果参数发生变化,您不必重新编译任何内容。您只需使用文本编辑器编辑 html 即可,瞧!还可以在不同页面上使用不同参数的代码的可重用性。
基本上,这与“当您可以将所有属性硬编码为某个类中的
public static String
字段时,为什么我们需要 *.properties 文件?”是同一个问题。You don't have to recompile anything if the param changes. You can just edit html with text editor and voilà! Also reusability of code with different params on different pages.
Basically it's the same question as "why do we need *.properties file when you can hardcode all the properties as
public static String
fields in some class?".一个简单的例子可能是通用菜单小程序。您不希望菜单存在于代码中,因为您可能想要更改它或在不同的网页上有不同的菜单。要显示的菜单可以轻松地在
param
标签中定义。A simple example might be a general-purpose menu applet. You don't want to have the menu existing in code, because you might want to change it or have different menus on different web pages. The menu to display can easily be defined in
param
tags.您可以拥有一个显示广告/验证码/其他内容并需要公钥的组件。相同的组件(无需重新编译)可以嵌入到多个站点上。公钥作为参数传递。
可以自定义小程序的外观(背景颜色、字体大小等),以更好地匹配整体网页布局。
奇妙的飞行独角兽动画可以具有可定制的速度和独角兽颜色。
You can have a component that displays advertisements/captchas/whatever and requires a public key. The same component (without recompiling) can be embedded on several sites. The public key is passes as a parameter.
The applets' look-and-feel (background colour, font sizes, etc.) can be customized to better match overall web-page layout.
Marvelous flying unicorn animation can have customizable speed and unicorn colour.