如何在 Struts 1.1 中设置默认选中的 <html:radio>
How to set an <html:radio> checked by default in Struts 1.1
我正在尝试了解如何在使用带有自定义标记的 jsp 和 struts 1.1 时默认选中单选按钮。
当我这样写代码时:
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
....................................................................
<html:radio property="operazione" value="addizione" checked="checked">Addizione</html:radio>
<br />
日食说:
Undefined attribute name "checked"
当我尝试 运行 我的服务器上的这段代码时 Tomcat 这是我得到的:
Attribute checked invalid for tag radio according to TLD
我读过 this q/a 但它涉及 JavaScript...
你能帮帮我吗?
这不涉及javascript。您需要做的就是在相应的操作表单中设置 属性 值。加载页面时,在操作 class 中设置 actionForm.property=value
。如果您需要 javascript、
(function() {
// Set the value on loading the page
document.getElementByID("elementID").value=1;
})();
希望对您有所帮助。
我正在尝试了解如何在使用带有自定义标记的 jsp 和 struts 1.1 时默认选中单选按钮。
当我这样写代码时:
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
....................................................................
<html:radio property="operazione" value="addizione" checked="checked">Addizione</html:radio>
<br />
日食说:
Undefined attribute name "checked"
当我尝试 运行 我的服务器上的这段代码时 Tomcat 这是我得到的:
Attribute checked invalid for tag radio according to TLD
我读过 this q/a 但它涉及 JavaScript... 你能帮帮我吗?
这不涉及javascript。您需要做的就是在相应的操作表单中设置 属性 值。加载页面时,在操作 class 中设置 actionForm.property=value
。如果您需要 javascript、
(function() {
// Set the value on loading the page
document.getElementByID("elementID").value=1;
})();
希望对您有所帮助。