我想显示第二个密码输入字段,它基于从数据库中读取的布尔值。从数据库中读取的代码已经编写,并且可以正常工作。我遇到的问题是条件显示列表元素。 我知道jsp很少 - 谷歌搜索答案,并提出以下,女巫不工作。 代码:
<ul>
<li><label for="username">Username</label>
<input type="username" name="username" placeholder="username" required>
</li>
<li><label for="password">Password</label>
<input type="password" name="password" placeholder="password" required>
</li>
<!-- conditional display of a second password field -->
<%
if (@showDoublePasswords == true) {
%>
<li><label for="password">Password 2</label>
<input type="password" name="password" placeholder="password" required>
</li>
<% } %>
</ul>
答案 0 :(得分:8)
试试这个
<ul>
<li><label for="username">Username</label>
<input type="username" name="username" placeholder="username" required>
</li>
<li><label for="password">Password</label>
<input type="password" name="password" placeholder="password" required>
</li>
<!-- conditional display of a second password field -->
<%
//Remove '@'
if (showDoublePasswords == true)
{
%>
<li><label for="password">Password 2</label>
<input type="password" name="password" placeholder="password" required>
</li>
<% }
%>
</ul>
*