Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/85.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用JSP向html标记添加选中属性_Html_Jsp_Input_Radio Button_Checked - Fatal编程技术网

使用JSP向html标记添加选中属性

使用JSP向html标记添加选中属性,html,jsp,input,radio-button,checked,Html,Jsp,Input,Radio Button,Checked,我正在尝试解决一个问题,我需要用JSP将checked添加到html输入标记中,但运气不好 目前我有: isBoy = ""; isGirl = "checked"; <inp:radio value="first" checked="<%=isGirl%>"/> <inp:radio value="second" checked="<%=isBoy%>"/> 欢迎所有推荐! 谢谢。如果不想检查选中的属性,则需要删除该属性。请尝试: <

我正在尝试解决一个问题,我需要用JSP将
checked
添加到html输入标记中,但运气不好

目前我有:

isBoy = "";
isGirl = "checked";

<inp:radio value="first" checked="<%=isGirl%>"/>
<inp:radio value="second" checked="<%=isBoy%>"/>
欢迎所有推荐!
谢谢。

如果不想检查选中的属性,则需要删除该属性。请尝试:

 <%
    isBoy = "";
isGirl = "checked='checked'";
 %>
<inp:radio value="first" <%=isGirl%>"/>
<inp:radio value="second" <%=isBoy%>"/>

谢谢,我两个都试过了

<input value="first" checked />
<input value="second" />
 <%
    isBoy = "";
isGirl = "checked='checked'";
 %>
<inp:radio value="first" <%=isGirl%>"/>
<inp:radio value="second" <%=isBoy%>"/>