我正在尝试登录显示用户提供电子邮件和密码后所有数据的页面。我正在使用传统的MVC。我的 问题 当我尝试使用jstl foreach时,我得到了我说的错误 以上......
这是我的Dao登录。
public Boolean loginValidation(String emailAddress, String password) throws SQLException{
boolean status;
Connection dbConnection = null;
PreparedStatement ps;
String loginTableSql = "select * from etherweb where emailAddress=? and pwd=?";
dbConnection = getDBConnection();
ps = dbConnection.prepareStatement(loginTableSql);
ps.setString(1, emailAddress);
ps.setString(2, password);
ResultSet rst = ps.executeQuery();
status = rst.next();
if(status){
user.setFirstName(rst.getString("firstName"));
user.setLastName(rst.getString("lastName"));
user.setUserName(rst.getString("userName"));
System.out.println("Record Exists");
}
return status;
这是带getter + setter的模型
public class User {
String email;
String firstName;
String lastName;
String userName;
String password;
这是我的servlet验证登录
User users = new User();
users.setEmail(request.getParameter("emailAddress"));
users.setPassword(request.getParameter("pwd"));
UserDao dao = new UserDao();
try {
if (dao.loginValidation(users.getEmail(), users.getPassword())) {
request.setAttribute("pickle", users);
RequestDispatcher dispatch = request.getRequestDispatcher("check.jsp");
dispatch.forward(request, response);
} else {
System.out.println("Login unsuccessful");
RequestDispatcher dispatch = request.getRequestDispatcher("index.jsp");
dispatch.forward(request, response);
}
} catch (SQLException ex) {
Logger.getLogger(LoginServlet.class.getName()).log(Level.SEVERE, null, ex);
}
这是我的错误来自的页面,这是用于显示数据的jsp页面。
<c:forEach items="${pickle}" var="lame">
<center><table border=1>
<thead>
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>UserName</th>
<th>Email</th>
<th>Password:</th>
</tr>
</thead>
</center>
<tbody>
<tr>
<td>${lame}</td>
</tr>
</c:forEach>
</tbody>
</table>
这是错误
org.apache.jasper.JasperException: An exception occurred processing JSP page /check.jsp at line 32
<c:forEach items="${pickle}" var="lame">
<center><table border=1>
<thead>
我虽然错误可能只是沿途的某种类型,但似乎没有任何效果。我的最后一个想法是只使用request.getParameter和ditch jstl,但我认为这是不好的做法所以我被告知......