【发布时间】:2015-12-11 15:35:07
【问题描述】:
我想根据从数据库中读取的布尔值显示第二个密码输入字段。从数据库中读取的代码已经编写好了,并且可以正常工作。我遇到的问题是列表元素的条件显示。 我对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>
【问题讨论】:
-
if (@showDoublePasswords == true) {..这是错误的..变量名不能以符号开头...除了$和_ -
删除 @ 您可以使用您在示例中使用的脚本 () 或 jstl 标记库来执行 if。 jstl 更干净一些。
标签: html jsp conditional show