【问题标题】:JSTL: How to check if username is in the databaseJSTL:如何检查用户名是否在数据库中
【发布时间】:2015-03-14 03:24:58
【问题描述】:

我想在“我的个人资料”模式中显示来自数据库的用户详细信息。我在 login.jsp 页面中使用 JSTL。这是我尝试过的(以及其他一些变体),但没有任何结果。数据库连接正常!。表名是users,我想在表中找到合适的用户。当有效用户登录时,我会收到来自 index.jsp 的请求 username

<c:forEach var="user" items="${users.rows}" >
<c:if test="${username}" == "${user.username}"> // <-- This is NOT working!

如果 username${user.username} 匹配,那么我想在模态中显示用户的信息,例如:

<c:out value="${user.fullName}"/>
<c:out value="${user.occupation}"/>
<c:out value="${user.email}"/>
<fmt:formatDate type="both" dateStyle="short" timeStyle="short" value="${user.joined}"/>

【问题讨论】:

    标签: database jsp servlets jstl


    【解决方案1】:

    我正在寻找的答案是&lt;c:if test="${username eq user.username}"&gt; 现在可以正常工作了。我希望它也能帮助其他人:)

    【讨论】:

      猜你喜欢
      • 2021-12-28
      • 1970-01-01
      • 1970-01-01
      • 2021-03-20
      • 2021-12-15
      • 1970-01-01
      • 1970-01-01
      • 2016-10-09
      相关资源
      最近更新 更多