我如何 select 在 JSP 中动态设置一个值
How can I select a value dinamically in JSP
我想使用 scriptlet select 标记 select 中的一个值,但它不起作用。
我怎样才能做到这一点?
提前致谢。
<%int number=2;%>
<br><br>Matricula:
<select id="mat" name="mat" >
<option<%if(number==1){%>selected<%}%> >
01</option>
<option<%if(number==2){%>selected<%}%> >
02</option>
<option<%if(number==3){%>selected<%}%> >
03</option>
<option<%if(number==4){%>selected<%}%> >
04</option>
</select>
您需要在 option
和 selected
之间添加 space
<%int number=2;%>
<br><br>Matricula:
<select id="mat" name="mat" >
<option <%if(number==1){%>selected<%}%> >
01</option>
<option <%if(number==2){%>selected<%}%> >
02</option>
<option <%if(number==3){%>selected<%}%> >
03</option>
<option <%if(number==4){%>selected<%}%> >
04</option>
</select>
我想使用 scriptlet select 标记 select 中的一个值,但它不起作用。 我怎样才能做到这一点?
提前致谢。
<%int number=2;%>
<br><br>Matricula:
<select id="mat" name="mat" >
<option<%if(number==1){%>selected<%}%> >
01</option>
<option<%if(number==2){%>selected<%}%> >
02</option>
<option<%if(number==3){%>selected<%}%> >
03</option>
<option<%if(number==4){%>selected<%}%> >
04</option>
</select>
您需要在 option
和 selected
<%int number=2;%>
<br><br>Matricula:
<select id="mat" name="mat" >
<option <%if(number==1){%>selected<%}%> >
01</option>
<option <%if(number==2){%>selected<%}%> >
02</option>
<option <%if(number==3){%>selected<%}%> >
03</option>
<option <%if(number==4){%>selected<%}%> >
04</option>
</select>