gpt4 book ai didi

java - 如何在JSP中动态选择一个值

转载 作者:行者123 更新时间:2023-12-02 11:04:37 25 4
gpt4 key购买 nike

我想使用 scriptlet 在选择标记中选择一个值,但它不起作用。我怎样才能实现这个目标?

提前致谢。

<%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>

最佳答案

您需要在选项所选之间添加空格

<%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>

关于java - 如何在JSP中动态选择一个值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51072088/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com