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

时间:2015-01-15 16:40:18

标签: database jsp servlets jstl

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

<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}"/>

1 个答案:

答案 0 :(得分:0)

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