JSTL核心标签forEach没有出现在JSP上


<h1>Customer Lists</h1>
<div>
<table border="1">
<tr>
<th>Customer Name</th>
<th>Email</th>
<th>Password</th>
<th>Phone</th>
<th>Country</th>
<th>Actions</th>
</tr>
<c:forEach var="e" items="${listofcustomers}" begin="0">
<c:url var="deleteLink" value="/deleteCustomer">
<c:param name="customerId" value="${e.cust_id}" />
</c:url>
<c:url var="updateLink" value="/editCustomer">
<c:param name="customerId" value="${e.cust_id}" />
</c:url>
<tr>
<td>${e.cust_name}</td>
<td>${e.cust_email}</td>
<td>${e.cust_pw}</td>
<td>${e.cust_phone}</td>
<td>${e.cust_country}</td>
<td><a href="${updateLink}">Update</a> <a href="${deleteLink}"
onclick="if(!(confirm('Are you sure you want to delete '))) return false;">
Delete</a></td>
</tr>
</c:forEach>

</table>
<a href="adminlist">Admin List</a>
</div>

这是控制器类的功能

@RequestMapping("/login")
public ModelAndView login(@ModelAttribute("customer") Customer customer, BindingResult result) {
ModelAndView mav = new ModelAndView();
try {
if (customer.getCust_pw().equals("")) {
result.rejectValue("cust_pw", "error.empty.pw");
mav = new ModelAndView("login");
}
else if (customer.getCust_email().equals("")) {
result.rejectValue("cust_email", "error.empty.email");
return mav = new ModelAndView("login");
}
else if (mapper.findByEmail(customer.getCust_email()) == null) {
result.rejectValue("cust_email", "error.mismatch.email");
mav = new ModelAndView("login");
}
else if (!customer.getCust_pw().equals(mapper.checkPw(customer.getCust_email()))) {
result.rejectValue("cust_pw", "error.mismatch.pw");
mav = new ModelAndView("login");
}
else {
System.out.println(mapper.getAllCustomer());
mav = new ModelAndView("index");
mav.addObject("listofcustomers", mapper.getAllCustomer());
}
} catch (Exception e) {
e.printStackTrace();
}
return mav;
}

这是mapper.java 的函数

@Repository
public class CustomerMapper {
public List<Customer> getAllCustomer() {
SqlSession session = MyBatilUtil.getSqlSessionFactory().openSession();
List<Customer> customerList = session.selectList("getAllCustomer");
session.commit();
session.close();
return customerList;
}

我对这个春天的mvc还是个新手。我希望你们能帮我解决这个问题。当我尝试使用springMVC运行代码时,forEach不会显示在页面中。我已经在jsp上声明了taglib。我的jsp有什么问题吗?或者可能是控制器部分的逻辑?

要使用JSTL,请尝试使用以下

<%@ taglib prefix = "c" uri = "http://java.sun.com/jsp/jstl/core" %>

相关内容

  • 没有找到相关文章

最新更新