JSTL:如何检查用户名是否在数据库中

JSTL: How to check if username is in the database

我想在 "my profile" 模式中显示数据库中的用户详细信息。我在 login.jsp 页面中使用 JSTL。这是我尝试过的(以及其他一些变体)但没有任何结果。数据库连接正常! Table 名字是 users,我想在 table 中找到合适的用户。当有效用户登录时,我从 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}"/>

我一直在寻找的答案是<c:if test="${username eq user.username}">它现在工作正常。我希望它也能帮助其他人:)