Java 如何在JSP中自动选择一个值
我想使用scriptlet在select标记中选择一个值,但它不起作用。 我怎样才能做到这一点 提前谢谢Java 如何在JSP中自动选择一个值,java,html,jsp,servlets,scriptlet,Java,Html,Jsp,Servlets,Scriptlet,我想使用scriptlet在select标记中选择一个值,但它不起作用。 我怎样才能做到这一点 提前谢谢 <%int number=2;%> <br><br>Matricula: <select id="mat" name="mat" > <option<%if(number==1){%>selected<%}%> > 01</option> <option<%if(number==
<%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>
母系:
01
02
03
04
您需要在选项
和所选之间添加空格
<%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>
母系:
01
02
03
04